Class: Slingshot::Search::Query
- Inherits:
-
Object
- Object
- Slingshot::Search::Query
- Defined in:
- lib/slingshot/search/query.rb
Instance Method Summary collapse
- #all ⇒ Object
- #ids(values, type) ⇒ Object
-
#initialize(&block) ⇒ Query
constructor
A new instance of Query.
- #string(value, options = {}) ⇒ Object
- #term(field, value) ⇒ Object
- #terms(field, value, options = {}) ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(&block) ⇒ Query
Returns a new instance of Query.
5 6 7 |
# File 'lib/slingshot/search/query.rb', line 5 def initialize(&block) self.instance_eval(&block) if block_given? end |
Instance Method Details
#all ⇒ Object
26 27 28 29 |
# File 'lib/slingshot/search/query.rb', line 26 def all @value = { :match_all => {} } @value end |
#ids(values, type) ⇒ Object
31 32 33 |
# File 'lib/slingshot/search/query.rb', line 31 def ids(values, type) @value = { :ids => { :values => values, :type => type } } end |
#string(value, options = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/slingshot/search/query.rb', line 19 def string(value, ={}) @value = { :query_string => { :query => value } } @value[:query_string].update( { :default_field => [:default_field] } ) if [:default_field] # TODO: https://github.com/elasticsearch/elasticsearch/wiki/Query-String-Query @value end |
#term(field, value) ⇒ Object
9 10 11 |
# File 'lib/slingshot/search/query.rb', line 9 def term(field, value) @value = { :term => { field => value } } end |
#terms(field, value, options = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/slingshot/search/query.rb', line 13 def terms(field, value, ={}) @value = { :terms => { field => value } } @value[:terms].update( { :minimum_match => [:minimum_match] } ) if [:minimum_match] @value end |
#to_json ⇒ Object
35 36 37 |
# File 'lib/slingshot/search/query.rb', line 35 def to_json @value.to_json end |