Class: ElasticQueryBuilder::Engine
- Inherits:
-
Object
- Object
- ElasticQueryBuilder::Engine
- Defined in:
- lib/elasticquerybuilder.rb
Overview
main class that generates elastic criteria
Instance Attribute Summary collapse
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
Instance Method Summary collapse
- #bool ⇒ Object
-
#initialize ⇒ Engine
constructor
A new instance of Engine.
-
#must ⇒ Object
opts = [field,value,operation,field,value,operation].
- #should ⇒ Object
- #single_match(opts) ⇒ Object
-
#term(opts) ⇒ Object
used for matching strings.
-
#terms(opts, default_operator = 'in') ⇒ Object
used for matching a value within an array.
-
#wildcard(opts, default_operator = 'wildcard') ⇒ Object
used for wildcards.
Constructor Details
#initialize ⇒ Engine
Returns a new instance of Engine.
8 9 10 11 |
# File 'lib/elasticquerybuilder.rb', line 8 def initialize @criteria = { query: {} } @modal = '' end |
Instance Attribute Details
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
7 8 9 |
# File 'lib/elasticquerybuilder.rb', line 7 def criteria @criteria end |
Instance Method Details
#bool ⇒ Object
43 44 45 46 |
# File 'lib/elasticquerybuilder.rb', line 43 def bool @criteria[:query] = { bool: {} } self end |
#must ⇒ Object
opts = [field,value,operation,field,value,operation]
14 15 16 17 |
# File 'lib/elasticquerybuilder.rb', line 14 def must @modal = ElasticQueryBuilder::Modals.must self end |
#should ⇒ Object
38 39 40 41 |
# File 'lib/elasticquerybuilder.rb', line 38 def should @modal = ElasticQueryBuilder::Modals.should self end |
#single_match(opts) ⇒ Object
34 35 36 |
# File 'lib/elasticquerybuilder.rb', line 34 def single_match(opts) setup_query('match', opts) end |
#term(opts) ⇒ Object
used for matching strings
20 21 22 |
# File 'lib/elasticquerybuilder.rb', line 20 def term(opts) setup_query('term', opts) end |
#terms(opts, default_operator = 'in') ⇒ Object
used for matching a value within an array
25 26 27 |
# File 'lib/elasticquerybuilder.rb', line 25 def terms(opts, default_operator = 'in') setup_query('terms', opts, default_operator) end |
#wildcard(opts, default_operator = 'wildcard') ⇒ Object
used for wildcards. supports whole wildcard, left and right matching
30 31 32 |
# File 'lib/elasticquerybuilder.rb', line 30 def wildcard(opts, default_operator = 'wildcard') setup_query('wildcard', opts, default_operator) end |