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 Stretchy::Clauses::Base#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
- #boost_match(params = {}, options = {}) ⇒ Object
- #fulltext(params = {}, options = {}) ⇒ Object
-
#match(*args) ⇒ MatchClause
Returns to the base context.
-
#not(params = {}) ⇒ 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, #field, #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, #initialize, #inverse?, #limit, #offset, #page, #query_results, #root, #should
Constructor Details
This class inherits a constructor from Stretchy::Clauses::Base
Instance Method Details
#boost_match(params = {}, options = {}) ⇒ Object
35 36 37 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 35 def boost_match(params = {}, = {}) match_function(hashify_params(params), ) end |
#fulltext(params = {}, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 39 def fulltext(params = {}, = {}) _params = hashify_params(params) weight = _params.delete(:weight) || [:weight] [:min] ||= MatchClause::FULLTEXT_MIN [:slop] ||= MatchClause::FULLTEXT_SLOP [:type] ||= Queries::MatchQuery::MATCH_TYPES.first clause = MatchClause.new.match(_params, ) boost = clause.to_boost(weight) base.boost_builder.add_boost(boost) if boost Base.new(base) end |
#match(*args) ⇒ MatchClause
Returns to the base context. Queries passed here will be used to filter documents.
81 82 83 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 81 def match(*args) MatchClause.new(base).match(*args) end |
#not(params) ⇒ BoostMatchClause #not(params) ⇒ BoostMatchClause
Switches to inverse context, and applies filters as inverse options (ie, documents that do not match the query will be boosted)
30 31 32 33 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 30 def not(params = {}) @inverse = true match_function(hashify_params(params)) end |
#where(*args) ⇒ WhereClause
Returns to the base context; filters passed here will be used to filter documents.
64 65 66 |
# File 'lib/stretchy/clauses/boost_match_clause.rb', line 64 def where(*args) WhereClause.new(base).where(*args) end |