class OpenSearch::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 opensearch.org/guide/en/opensearch/reference/current/query-dsl-query-filter.html
Public Class Methods
new(*args, &block)
click to toggle source
Calls superclass method
OpenSearch::DSL::Search::BaseComponent::new
# File lib/opensearch/dsl/search/filters/query.rb, line 55 def initialize(*args, &block) super if block @query = OpenSearch::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/opensearch/dsl/search/filters/query.rb, line 67 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