Class: Couchbase::SearchRowLocations

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/search_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(locations) ⇒ SearchRowLocations

Returns a new instance of SearchRowLocations.

Parameters:



1396
1397
1398
1399
# File 'lib/couchbase/search_options.rb', line 1396

def initialize(locations)
  super()
  @locations = locations
end

Instance Method Details

#fieldsArray<String>

Lists the fields in this location

Returns:

  • (Array<String>)


1377
1378
1379
# File 'lib/couchbase/search_options.rb', line 1377

def fields
  @locations.map(&:field).uniq
end

#get_allArray<SearchRowLocation>

Lists all locations (any field, any term)

Returns:



1356
1357
1358
# File 'lib/couchbase/search_options.rb', line 1356

def get_all
  @locations
end

#get_for_field(name) ⇒ Array<SearchRowLocation>

Lists all locations for a given field (any term)

Returns:



1363
1364
1365
# File 'lib/couchbase/search_options.rb', line 1363

def get_for_field(name)
  @locations.select { |location| location.field == name }
end

#get_for_field_and_term(name, term) ⇒ Array<SearchRowLocation>

Lists all locations for a given field and term

Returns:



1370
1371
1372
# File 'lib/couchbase/search_options.rb', line 1370

def get_for_field_and_term(name, term)
  @locations.select { |location| location.field == name && location.term == term }
end

#termsArray<String>

Lists all terms in this locations, considering all fields

Returns:

  • (Array<String>)


1384
1385
1386
# File 'lib/couchbase/search_options.rb', line 1384

def terms
  @locations.map(&:term).uniq
end

#terms_for_field(name) ⇒ Array<String>

Lists the terms for a given field

Returns:

  • (Array<String>)


1391
1392
1393
# File 'lib/couchbase/search_options.rb', line 1391

def terms_for_field(name)
  get_for_field(name).map(&:term).uniq
end