Class: Couchbase::SearchQuery::ConjunctionQuery

Inherits:
Couchbase::SearchQuery show all
Defined in:
lib/couchbase/search_options.rb,
/code/couchbase-ruby-client/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:



742
743
744
745
746
# File 'lib/couchbase/search_options.rb', line 742

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

Instance Attribute Details

#boostFloat

Returns:

  • (Float)


737
738
739
# File 'lib/couchbase/search_options.rb', line 737

def boost
  @boost
end

Instance Method Details

#and_also(*queries) ⇒ Object

Parameters:



749
750
751
# File 'lib/couchbase/search_options.rb', line 749

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

#empty?Boolean

Returns:

  • (Boolean)


753
754
755
# File 'lib/couchbase/search_options.rb', line 753

def empty?
  @queries.empty?
end

#to_hHash<Symbol, #to_json>

Returns:

Raises:



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

def to_h
  raise Error::InvalidArgument, "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