class Elasticsearch::DSL::Search::Filters::Nested
A filter which executes another filter in the context of a nested document
@example
search do query do filtered do filter do nested do path 'comments' filter do term 'comments.title' => 'Ruby' end end end end end end
@see www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-filter.html
Public Instance Methods
filter(*args, &block)
click to toggle source
DSL
method for building the `filter` part of the query definition
@return [self]
# File lib/elasticsearch/dsl/search/filters/nested.rb, line 53 def filter(*args, &block) @filter = block ? Filter.new(*args, &block) : args.first self end
query(*args, &block)
click to toggle source
# File lib/elasticsearch/dsl/search/filters/nested.rb, line 58 def query(*args, &block) @query = block ? Elasticsearch::DSL::Search::Query.new(*args, &block) : args.first self end
to_hash()
click to toggle source
Converts the query definition to a Hash
@return [Hash]
Calls superclass method
# File lib/elasticsearch/dsl/search/filters/nested.rb, line 67 def to_hash hash = super if @filter _filter = @filter.respond_to?(:to_hash) ? @filter.to_hash : @filter hash[self.name].update(filter: _filter) end if @query _query = @query.respond_to?(:to_hash) ? @query.to_hash : @query hash[self.name].update(query: _query) end hash end