Class: ElasticQuery::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_query/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ Builder

Returns a new instance of Builder.



5
6
7
# File 'lib/elastic_query/builder.rb', line 5

def initialize(query)
  self.query = Query.new(query)
end

Instance Attribute Details

#queryObject

Returns the value of attribute query.



3
4
5
# File 'lib/elastic_query/builder.rb', line 3

def query
  @query
end

Instance Method Details

#filter(filter_query) ⇒ Object



9
10
11
12
# File 'lib/elastic_query/builder.rb', line 9

def filter(filter_query)
  self.query = FilteredQuery.new(filter_query, query)
  self
end

#filter_nested(object_name, nested_query, options = {}) ⇒ Object



25
26
27
# File 'lib/elastic_query/builder.rb', line 25

def filter_nested(object_name, nested_query, options = {})
  filter(NestedQuery.new(object_name, nested_query, options))
end

#function_score(functions, options = {}) ⇒ Object



29
30
31
32
# File 'lib/elastic_query/builder.rb', line 29

def function_score(functions, options = {})
  self.query = FunctionScore.new(query, functions, options)
  self
end

#rescore(rescore_query, rescore_options = {}) ⇒ Object



14
15
16
17
# File 'lib/elastic_query/builder.rb', line 14

def rescore(rescore_query, rescore_options = {})
  self.query = RescoreQuery.new(query, rescore_query, rescore_options)
  self
end

#to_hashObject



19
20
21
22
23
# File 'lib/elastic_query/builder.rb', line 19

def to_hash
  {
    query: query.to_hash
  }
end