Class: Stretchy::Clauses::BoostMatchClause
- Inherits:
-
BoostClause
- Object
- Base
- BoostClause
- Stretchy::Clauses::BoostMatchClause
- Defined in:
- lib/stretchy/clauses/boost_match_clause.rb
Overview
Boost documents that match a free-text query. Most
options will be passed into #initialize, but you
can also chain .not
onto it. Calling .where
or
.match
from here will apply filters (not boosts)
and return to the base state
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(base, opts_or_string = {}, options = {}) ⇒ BoostMatchClause
constructor
Adds a match query to the boost functions.
-
#match(*args) ⇒ MatchClause
Returns to the base context.
-
#not(opts_or_string = {}) ⇒ BoostMatchClause
Switches to inverse context, and applies filters as inverse options (ie, documents that do not match the query will be boosted).
-
#where(*args) ⇒ WhereClause
Returns to the base context; filters passed here will be used to filter documents.
Methods inherited from BoostClause
#all, #boost_mode, #max, #near, #random, #score_mode
Methods inherited from Base
#aggregations, #boost, #explain, #fields, #get_aggregations, #get_explain, #get_fields, #get_limit, #get_offset, #get_page, #inverse?, #limit, #offset, #page, #query_results, #should
Constructor Details
#initialize(base, opts_or_string) ⇒ BoostMatchClause #initialize(base, opts_or_string) ⇒ BoostMatchClause
Adds a match query to the boost functions.
30 31 32 33 34 35 36 37 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 30 def initialize(base, opts_or_string = {}, = {}) super(base) if opts_or_string.is_a?(Hash) match_function(opts_or_string.merge()) else match_function(.merge('_all' => opts_or_string)) end end |
Instance Method Details
#match(*args) ⇒ MatchClause
Returns to the base context. Queries passed here will be used to filter documents.
91 92 93 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 91 def match(*args) MatchClause.new(base, *args) end |
#not(opts_or_string) ⇒ BoostMatchClause #not(opts_or_string) ⇒ BoostMatchClause
Switches to inverse context, and applies filters as inverse options (ie, documents that do not match the query will be boosted)
51 52 53 54 55 56 57 58 59 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 51 def not(opts_or_string = {}) @inverse = true if opts_or_string.is_a?(Hash) match_function(opts_or_string) else match_function('_all' => opts_or_string) end self end |
#where(*args) ⇒ WhereClause
Returns to the base context; filters passed here will be used to filter documents.
74 75 76 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 74 def where(*args) WhereClause.new(base, *args) end |