Class: Couchbase::Cluster::SearchQuery::ConjunctionQuery

Inherits:
Couchbase::Cluster::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::Cluster::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, wildcard

Constructor Details

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

Returns a new instance of ConjunctionQuery.

Parameters:

Yield Parameters:



671
672
673
674
675
# File 'lib/couchbase/search_options.rb', line 671

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

Instance Attribute Details

#boostFloat

Returns:

  • (Float)


666
667
668
# File 'lib/couchbase/search_options.rb', line 666

def boost
  @boost
end

Instance Method Details

#and_also(*queries) ⇒ Object

Parameters:



678
679
680
# File 'lib/couchbase/search_options.rb', line 678

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

#empty?Boolean

Returns:

  • (Boolean)


682
683
684
# File 'lib/couchbase/search_options.rb', line 682

def empty?
  @queries.empty?
end

#to_json(*args) ⇒ String

Returns:

  • (String)

Raises:

  • (ArgumentError)


687
688
689
690
691
692
693
# File 'lib/couchbase/search_options.rb', line 687

def to_json(*args)
  raise ArgumentError, "compound conjunction query must have sub-queries" if @queries.nil? || @queries.empty?

  data = {"conjuncts" => @queries.uniq}
  data["boost"] = boost if boost
  data.to_json(*args)
end