Class: ElasticsearchDslBuilder::DSL::Search::Queries::Nested
- Defined in:
- lib/elasticsearch_dsl_builder/dsl/search/queries/nested.rb
Instance Attribute Summary
Attributes inherited from Query
Instance Method Summary collapse
-
#initialize(path = nil) ⇒ Nested
constructor
A new instance of Nested.
- #inner_hits(inner_hits) ⇒ Object
- #path(path) ⇒ Object
- #query(query) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ Nested
Returns a new instance of Nested.
6 7 8 9 10 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/nested.rb', line 6 def initialize(path = nil) @type = :nested path(path) super() end |
Instance Method Details
#inner_hits(inner_hits) ⇒ Object
25 26 27 28 29 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/nested.rb', line 25 def inner_hits(inner_hits) raise ArgumentError, 'inner_hits must be an InnerHits object' unless inner_hits.instance_of?(InnerHits) @inner_hits = inner_hits self end |
#path(path) ⇒ Object
12 13 14 15 16 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/nested.rb', line 12 def path(path) raise ArgumentError, 'path must be a String' unless path.instance_of?(String) @path = path self end |
#query(query) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/nested.rb', line 18 def query(query) raise ArgumentError, 'query must extend type Queries::Query' unless query.is_a?(Query) @nested_query = query self end |
#to_hash ⇒ Object
31 32 33 34 35 36 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/nested.rb', line 31 def to_hash @query = { path: @path } @query.update(query: @nested_query.to_hash) if @nested_query @query.update(inner_hits: @inner_hits.to_hash) if @inner_hits super end |