Class: Couchbase::SearchRowLocations

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

Instance Method Summary collapse

Constructor Details

#initialize(locations) ⇒ SearchRowLocations

Returns a new instance of SearchRowLocations.

Parameters:



1518
1519
1520
1521
# File 'lib/couchbase/search_options.rb', line 1518

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

Instance Method Details

#fields ⇒ Array<String>

Lists the fields in this location

Returns:

  • (Array<String>)


1499
1500
1501
# File 'lib/couchbase/search_options.rb', line 1499

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

#get_all ⇒ Array<SearchRowLocation>

Lists all locations (any field, any term)

Returns:



1478
1479
1480
# File 'lib/couchbase/search_options.rb', line 1478

def get_all
  @locations
end

#get_for_field(name) ⇒ Array<SearchRowLocation>

Lists all locations for a given field (any term)

Returns:



1485
1486
1487
# File 'lib/couchbase/search_options.rb', line 1485

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:



1492
1493
1494
# File 'lib/couchbase/search_options.rb', line 1492

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

#terms ⇒ Array<String>

Lists all terms in this locations, considering all fields

Returns:

  • (Array<String>)


1506
1507
1508
# File 'lib/couchbase/search_options.rb', line 1506

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

#terms_for_field(name) ⇒ Array<String>

Lists the terms for a given field

Returns:

  • (Array<String>)


1513
1514
1515
# File 'lib/couchbase/search_options.rb', line 1513

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