Class: OpenSearch::DSL::Search::Filters::Nested
- Inherits:
-
Object
- Object
- OpenSearch::DSL::Search::Filters::Nested
- Includes:
- BaseComponent
- Defined in:
- lib/opensearch/dsl/search/filters/nested.rb
Overview
A filter which executes another filter in the context of a nested document
Instance Method Summary collapse
-
#filter(*args, &block) ⇒ self
DSL method for building the ‘filter` part of the query definition.
- #query(*args, &block) ⇒ Object
-
#to_hash ⇒ Hash
Converts the query definition to a Hash.
Methods included from BaseComponent
Instance Method Details
#filter(*args, &block) ⇒ self
DSL method for building the ‘filter` part of the query definition
62 63 64 65 |
# File 'lib/opensearch/dsl/search/filters/nested.rb', line 62 def filter(*args, &block) @filter = block ? Filter.new(*args, &block) : args.first self end |
#query(*args, &block) ⇒ Object
67 68 69 70 |
# File 'lib/opensearch/dsl/search/filters/nested.rb', line 67 def query(*args, &block) @query = block ? OpenSearch::DSL::Search::Query.new(*args, &block) : args.first self end |
#to_hash ⇒ Hash
Converts the query definition to a Hash
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/opensearch/dsl/search/filters/nested.rb', line 76 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 |