Class: Couchbase::Cluster::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:

[View source]

1293
1294
1295
# File 'lib/couchbase/search_options.rb', line 1293

def initialize(locations)
  @locations = locations
end

Instance Method Details

#fieldsArray<String>

Lists the fields in this location

Returns:

  • (Array<String>)
[View source]

1274
1275
1276
# File 'lib/couchbase/search_options.rb', line 1274

def fields
  @locations.map { |location| location.field }.uniq
end

#get_allArray<SearchRowLocation>

Lists all locations (any field, any term)

Returns:

[View source]

1253
1254
1255
# File 'lib/couchbase/search_options.rb', line 1253

def get_all
  @locations
end

#get_for_field(name) ⇒ Array<SearchRowLocation>

Lists all locations for a given field (any term)

Returns:

[View source]

1260
1261
1262
# File 'lib/couchbase/search_options.rb', line 1260

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]

1267
1268
1269
# File 'lib/couchbase/search_options.rb', line 1267

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]

1281
1282
1283
# File 'lib/couchbase/search_options.rb', line 1281

def terms
  @locations.map { |location| location.term }.uniq
end

#terms_for_field(name) ⇒ Array<String>

Lists the terms for a given field

Returns:

  • (Array<String>)
[View source]

1288
1289
1290
# File 'lib/couchbase/search_options.rb', line 1288

def terms_for_field(name)
  get_for_field(name).map { |location| location.term }.uniq
end