class Elasticsearch::DSL::Search::Filters::Query

A filter which wraps a query so it can be used as a filter

@example

search do
  query do
    filtered do
      filter do
        query do
          query_string :title do
            query 'Ruby OR Python'
          end
        end
      end
    end
  end
end

@see www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-filter.html

Public Class Methods

new(*args, &block) click to toggle source
# File lib/elasticsearch/dsl/search/filters/query.rb, line 46
def initialize(*args, &block)
  super
  if block
    @query = Elasticsearch::DSL::Search::Query.new(*args, &block)
    @block = nil
  end
end

Public Instance Methods

to_hash() click to toggle source

Converts the query definition to a Hash

@return [Hash]

Calls superclass method
# File lib/elasticsearch/dsl/search/filters/query.rb, line 58
def to_hash
  hash = super
  if @query
    _query = @query.respond_to?(:to_hash) ? @query.to_hash : @query
    hash[self.name].update(_query)
  end
  hash
end