Class: Couchbase::SearchQuery::ConjunctionQuery

Inherits:
Couchbase::SearchQuery show all
Defined in:
lib/couchbase/search_options.rb

Overview

Result documents must satisfy all of the child queries.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Couchbase::SearchQuery

boolean_field, booleans, conjuncts, date_range, disjuncts, doc_id, geo_bounding_box, geo_distance, geo_polygon, match, match_all, match_none, match_phrase, numeric_range, phrase, prefix, query_string, regexp, term, term_range, #to_json, wildcard

Constructor Details

#initialize(*queries) {|self| ... } ⇒ ConjunctionQuery

Returns a new instance of ConjunctionQuery.

Parameters:

Yield Parameters:



740
741
742
743
744
# File 'lib/couchbase/search_options.rb', line 740

def initialize(*queries)
  super()
  @queries = queries.flatten
  yield self if block_given?
end

Instance Attribute Details

#boostFloat

Returns:

  • (Float)


735
736
737
# File 'lib/couchbase/search_options.rb', line 735

def boost
  @boost
end

Instance Method Details

#and_also(*queries) ⇒ Object

Parameters:



747
748
749
# File 'lib/couchbase/search_options.rb', line 747

def and_also(*queries)
  @queries |= queries.flatten
end

#empty?Boolean

Returns:

  • (Boolean)


751
752
753
# File 'lib/couchbase/search_options.rb', line 751

def empty?
  @queries.empty?
end

#to_hHash<Symbol, #to_json>

Returns:

Raises:

  • (ArgumentError)


756
757
758
759
760
761
762
# File 'lib/couchbase/search_options.rb', line 756

def to_h
  raise ArgumentError, "compound conjunction query must have sub-queries" if @queries.nil? || @queries.empty?

  data = {:conjuncts => @queries.uniq.map(&:to_h)}
  data[:boost] = boost if boost
  data
end