Class: Stretchy::Queries::MatchQuery
- Defined in:
- lib/stretchy/queries/match_query.rb
Constant Summary collapse
- OPERATORS =
['and', 'or']
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MatchQuery
constructor
A new instance of MatchQuery.
- #to_search ⇒ Object
Methods included from Utils::Validation
#errors, included, #require_one!, #require_only_one!, #valid?, #validate!, #validator
Constructor Details
#initialize(options = {}) ⇒ MatchQuery
Returns a new instance of MatchQuery.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/stretchy/queries/match_query.rb', line 20 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
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/stretchy/queries/match_query.rb', line 34 def to_search { match: { @field => { query: @string, operator: @operator } } } end |