Class: Elasticquery::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticquery/query.rb

Constant Summary collapse

DEFAULT =
{query: {filtered: {query: {match_all:{}}}}}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query = DEFAULT) ⇒ Query

Returns a new instance of Query.



8
9
10
11
# File 'lib/elasticquery/query.rb', line 8

def initialize(query = DEFAULT)
  @query = query
  @filters, @queries = [], []
end

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.



4
5
6
# File 'lib/elasticquery/query.rb', line 4

def filters
  @filters
end

#queriesObject (readonly)

Returns the value of attribute queries.



4
5
6
# File 'lib/elasticquery/query.rb', line 4

def queries
  @queries
end

Instance Method Details

#push_filter(filter) ⇒ Object



17
18
19
20
# File 'lib/elasticquery/query.rb', line 17

def push_filter(filter)
  @filters << filter
  merge_filter filter
end

#push_query(query) ⇒ Object



22
23
24
25
# File 'lib/elasticquery/query.rb', line 22

def push_query(query)
  @queries << query
  merge_query query
end

#to_hashObject



13
14
15
# File 'lib/elasticquery/query.rb', line 13

def to_hash
  @query
end