Class: Couchbase::Cluster::SearchQuery::DisjunctionQuery

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

Overview

Result documents must satisfy a configurable min number of 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, match, match_all, match_none, match_phrase, numeric_range, phrase, prefix, query_string, regexp, term, term_range, wildcard

Constructor Details

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

Returns a new instance of DisjunctionQuery.

Parameters:

Yield Parameters:

[View source]

662
663
664
665
666
# File 'lib/couchbase/search_options.rb', line 662

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

Instance Attribute Details

#boostFloat

Returns:

  • (Float)

654
655
656
# File 'lib/couchbase/search_options.rb', line 654

def boost
  @boost
end

#minInteger

Returns:

  • (Integer)

657
658
659
# File 'lib/couchbase/search_options.rb', line 657

def min
  @min
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)
[View source]

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

def empty?
  @queries.empty?
end

#or_else(*queries) ⇒ Object

Parameters:

[View source]

669
670
671
# File 'lib/couchbase/search_options.rb', line 669

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

#to_json(*args) ⇒ String

Returns:

  • (String)

Raises:

  • (ArgumentError)
[View source]

678
679
680
681
682
683
684
685
686
687
# File 'lib/couchbase/search_options.rb', line 678

def to_json(*args)
  raise ArgumentError, "compound disjunction query must have sub-queries" if @queries.nil? || @queries.empty?
  data = {"disjuncts" => @queries.uniq}
  if min
    raise ArgumentError, "disjunction query has fewer sub-queries than configured minimum" if @queries.size < min
    data["min"] = min
  end
  data["boost"] = boost if boost
  data.to_json(*args)
end