Class: Stretchy::Clauses::BoostMatchClause

Inherits:
BoostClause show all
Defined in:
lib/stretchy/clauses/boost_match_clause.rb

Constant Summary

Constants inherited from Base

Stretchy::Clauses::Base::DEFAULT_LIMIT, Stretchy::Clauses::Base::DEFAULT_OFFSET

Instance Attribute Summary

Attributes inherited from Base

#aggregate_builder, #boost_builder, #index_name, #inverse, #match_builder, #type, #where_builder

Instance Method Summary collapse

Methods inherited from BoostClause

#all, #boost_mode, #max, #near, #random, #score_mode

Methods inherited from Base

#boost, #get_limit, #get_offset, #inverse?, #limit, #offset, #query_results, #should, #to_search

Constructor Details

#initialize(base, opts_or_string = {}, options = {}) ⇒ BoostMatchClause

Returns a new instance of BoostMatchClause.



9
10
11
12
13
14
15
16
17
18
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 9

def initialize(base, opts_or_string = {}, options = {})
  super(base)
  if opts_or_string.is_a?(Hash)
    @inverse = opts_or_string.delete(:inverse) || options.delete(:inverse)
    match_function(opts_or_string.merge(options))
  else
    @inverse = options.delete(:inverse)
    match_function(options.merge('_all' => opts_or_string))
  end
end

Instance Method Details

#match(*args) ⇒ Object



28
29
30
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 28

def match(*args)
  MatchClause.new(self, *args)
end

#not(opts_or_string = {}, options = {}) ⇒ Object



20
21
22
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 20

def not(opts_or_string = {}, options = {})
  self.class.new(self, opts_or_string, options.merge(inverse: !inverse?))
end

#where(*args) ⇒ Object



24
25
26
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 24

def where(*args)
  WhereClause.new(self, *args)
end