Class: Eson::Search::BaseQuery
- Inherits:
-
Object
- Object
- Eson::Search::BaseQuery
- Includes:
- Facets, Parametrized, QueryGroup
- Defined in:
- lib/eson/search/base_query.rb
Instance Attribute Summary
Attributes included from Parametrized
Attributes included from Queries
Attributes included from Filters
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ BaseQuery
constructor
A new instance of BaseQuery.
- #to_query_hash ⇒ Object
Methods included from Parametrized
Methods included from Facets
Methods included from QueryGroup
Methods included from Queries
Methods included from Filters
Constructor Details
#initialize(args = {}) ⇒ BaseQuery
Returns a new instance of BaseQuery.
8 9 10 11 |
# File 'lib/eson/search/base_query.rb', line 8 def initialize(args = {}) self.args = args instance_exec(self, &Proc.new) if block_given? end |
Instance Method Details
#to_query_hash ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/eson/search/base_query.rb', line 13 def to_query_hash if (!queries || queries.empty?) hash = {:query => {:match_all => {}}} else hash = {:query => queries.to_query_hash } end if filters && !filters.empty? if filters.length > 1 hash[:filter] = {:and => filter.to_query_hash} else hash[:filter] = filter.to_query_hash end end if facets.length > 0 hash[:facets] = facets.to_query_hash end hash end |