Class: Couchbase::SearchQuery::BooleanQuery
Overview
The boolean query is a useful combination of conjunction and disjunction queries.
Instance Attribute Summary collapse
Instance Method Summary
collapse
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 {|self| ... } ⇒ BooleanQuery
Returns a new instance of BooleanQuery.
Instance Attribute Details
#boost ⇒ Float
829
830
831
|
# File 'lib/couchbase/search_options.rb', line 829
def boost
@boost
end
|
Instance Method Details
#must(*queries) ⇒ Object
847
848
849
850
|
# File 'lib/couchbase/search_options.rb', line 847
def must(*queries)
@must.and_also(*queries)
self
end
|
#must_not(*queries) ⇒ Object
853
854
855
856
|
# File 'lib/couchbase/search_options.rb', line 853
def must_not(*queries)
@must_not.or_else(*queries)
self
end
|
#should(*queries) ⇒ Object
859
860
861
862
|
# File 'lib/couchbase/search_options.rb', line 859
def should(*queries)
@should.or_else(*queries)
self
end
|
#should_min(min) ⇒ Object
841
842
843
844
|
# File 'lib/couchbase/search_options.rb', line 841
def should_min(min)
@should.min = min
self
end
|
#to_h ⇒ Hash<Symbol, #to_json>
865
866
867
868
869
870
871
872
873
874
875
876
877
|
# File 'lib/couchbase/search_options.rb', line 865
def to_h
if @must.empty? && @must_not.empty? && @should.empty?
raise Error::InvalidArgument,
"BooleanQuery must have at least one non-empty sub-query"
end
data = {}
data[:must] = @must.to_h unless @must.empty?
data[:must_not] = @must_not.to_h unless @must_not.empty?
data[:should] = @should.to_h unless @should.empty?
data[:boost] = boost if boost
data
end
|