Class: Stretchy::Queries::MatchQuery
- Defined in:
- lib/stretchy/queries/match_query.rb
Constant Summary collapse
- OPERATORS =
['and', 'or']
Constants included from Utils::Contract
Utils::Contract::ASSERTIONS, Utils::Contract::DECAY_FUNCTIONS, Utils::Contract::DISTANCE_FORMAT
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MatchQuery
constructor
A new instance of MatchQuery.
- #to_search ⇒ Object
Methods included from Utils::Contract
included, #require_one, #validate!
Constructor Details
#initialize(options = {}) ⇒ MatchQuery
Returns a new instance of MatchQuery.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/stretchy/queries/match_query.rb', line 13 def initialize( = {}) case when String @field = '_all' @string = @operator = 'and' when Hash @field = [:field] || '_all' @string = [:string] @operator = [:operator] || 'and' end validate! end |
Instance Method Details
#to_search ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stretchy/queries/match_query.rb', line 27 def to_search { match: { @field => { query: @string, operator: @operator } } } end |