Class: Couchbase::SearchQuery::TermQuery

Inherits:
SearchQuery
  • Object
show all
Defined in:
lib/couchbase/search_options.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/lib/couchbase/search_options.rb

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

Constructor Details

#initialize(term) {|self| ... } ⇒ TermQuery

Returns a new instance of TermQuery.

Parameters:

  • term (String)

Yield Parameters:



904
905
906
907
908
# File 'lib/couchbase/search_options.rb', line 904

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

Instance Attribute Details

#boost ⇒ Float

Returns:

  • (Float)


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

def boost
  @boost
end

#field ⇒ String

Returns:

  • (String)


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

def field
  @field
end

#fuzziness ⇒ Integer

Returns:

  • (Integer)


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

def fuzziness
  @fuzziness
end

#prefix_length ⇒ Integer

Returns:

  • (Integer)


899
900
901
# File 'lib/couchbase/search_options.rb', line 899

def prefix_length
  @prefix_length
end

Instance Method Details

#to_h ⇒ Hash<Symbol, #to_json>

Returns:



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

def to_h
  data = {:term => @term}
  data[:boost] = boost if boost
  data[:field] = field if field
  if fuzziness
    data[:fuzziness] = fuzziness
    data[:prefix_length] = prefix_length if prefix_length
  end
  data
end