Class: Couchbase::SearchRowLocations

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/search_options.rb,
/code/couchbase-ruby-client/lib/couchbase/search_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(locations) ⇒ SearchRowLocations

Returns a new instance of SearchRowLocations.

Parameters:



1424
1425
1426
1427
# File 'lib/couchbase/search_options.rb', line 1424

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

Instance Method Details

#fieldsArray<String>

Lists the fields in this location

Returns:

  • (Array<String>)


1405
1406
1407
# File 'lib/couchbase/search_options.rb', line 1405

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

#get_allArray<SearchRowLocation>

Lists all locations (any field, any term)

Returns:



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

def get_all
  @locations
end

#get_for_field(name) ⇒ Array<SearchRowLocation>

Lists all locations for a given field (any term)

Returns:



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

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:



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

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>)


1412
1413
1414
# File 'lib/couchbase/search_options.rb', line 1412

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

#terms_for_field(name) ⇒ Array<String>

Lists the terms for a given field

Returns:

  • (Array<String>)


1419
1420
1421
# File 'lib/couchbase/search_options.rb', line 1419

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