Class: Couchbase::Cluster::SearchQuery::TermQuery

Inherits:
Couchbase::Cluster::SearchQuery show all
Defined in:
lib/couchbase/search_options.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/search_options.rb
more...

Overview

A query that looks for exact matches of the term in the index (no analyzer, no stemming). Useful to check what the actual content of the index is. It can also apply fuzziness on the term. Usual better alternative is ‘MatchQuery`.

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(term) {|self| ... } ⇒ TermQuery

Returns a new instance of TermQuery.

Parameters:

  • term (String)

Yield Parameters:

[View source]

902
903
904
905
906
# File 'lib/couchbase/search_options.rb', line 902

def initialize(term)
  super()
  @term = term
  yield self if block_given?
end

Instance Attribute Details

#boostFloat

Returns:

  • (Float)

885
886
887
# File 'lib/couchbase/search_options.rb', line 885

def boost
  @boost
end

#fieldString

Returns:

  • (String)

891
892
893
# File 'lib/couchbase/search_options.rb', line 891

def field
  @field
end

#fuzzinessInteger

Returns:

  • (Integer)

894
895
896
# File 'lib/couchbase/search_options.rb', line 894

def fuzziness
  @fuzziness
end

#operatornil, ...

Returns:

  • (nil, :or, :and)

888
889
890
# File 'lib/couchbase/search_options.rb', line 888

def operator
  @operator
end

#prefix_lengthInteger

Returns:

  • (Integer)

897
898
899
# File 'lib/couchbase/search_options.rb', line 897

def prefix_length
  @prefix_length
end

Instance Method Details

#to_json(*args) ⇒ String

Returns:

  • (String)
[View source]

909
910
911
912
913
914
915
916
917
918
919
920
# File 'lib/couchbase/search_options.rb', line 909

def to_json(*args)
  data = {"term" => @term}
  data["boost"] = boost if boost
  data["operator"] = operator.to_s if operator
  data["operator"] = operator.to_s if operator
  data["field"] = field if field
  if fuzziness
    data["fuzziness"] = fuzziness
    data["prefix_length"] = prefix_length if prefix_length
  end
  data.to_json(*args)
end