Class: Couchbase::Cluster::SearchRowLocations

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

Instance Method Summary collapse

Constructor Details

#initialize(locations) ⇒ SearchRowLocations

Returns a new instance of SearchRowLocations.

Parameters:

[View source]

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

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

Instance Method Details

#fieldsArray<String>

Lists the fields in this location

Returns:

  • (Array<String>)
[View source]

1338
1339
1340
# File 'lib/couchbase/search_options.rb', line 1338

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

#get_allArray<SearchRowLocation>

Lists all locations (any field, any term)

Returns:

[View source]

1317
1318
1319
# File 'lib/couchbase/search_options.rb', line 1317

def get_all
  @locations
end

#get_for_field(name) ⇒ Array<SearchRowLocation>

Lists all locations for a given field (any term)

Returns:

[View source]

1324
1325
1326
# File 'lib/couchbase/search_options.rb', line 1324

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:

[View source]

1331
1332
1333
# File 'lib/couchbase/search_options.rb', line 1331

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>)
[View source]

1345
1346
1347
# File 'lib/couchbase/search_options.rb', line 1345

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

#terms_for_field(name) ⇒ Array<String>

Lists the terms for a given field

Returns:

  • (Array<String>)
[View source]

1352
1353
1354
# File 'lib/couchbase/search_options.rb', line 1352

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