Class: ElasticsearchDslBuilder::DSL::Search::Queries::HasParent
- Defined in:
- lib/elasticsearch_dsl_builder/dsl/search/queries/has_parent.rb
Instance Attribute Summary
Attributes inherited from Query
Instance Method Summary collapse
-
#initialize(parent_type) ⇒ HasParent
constructor
A new instance of HasParent.
- #inner_hits(inner_hits) ⇒ Object
- #parent_type(parent_type) ⇒ Object
- #query(query) ⇒ Object
- #score(score) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(parent_type) ⇒ HasParent
Returns a new instance of HasParent.
6 7 8 9 10 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/has_parent.rb', line 6 def initialize(parent_type) @type = :has_parent parent_type(parent_type) super() end |
Instance Method Details
#inner_hits(inner_hits) ⇒ Object
33 34 35 36 37 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/has_parent.rb', line 33 def inner_hits(inner_hits) raise ArgumentError, 'inner_hits must be an InnerHits object' unless inner_hits.instance_of?(InnerHits) @inner_hits = inner_hits.to_hash self end |
#parent_type(parent_type) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/has_parent.rb', line 12 def parent_type(parent_type) raise ArgumentError, 'parent_type must be a String' unless parent_type.instance_of?(String) @parent_type = parent_type self end |
#query(query) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/has_parent.rb', line 26 def query(query) raise ArgumentError, 'query must extend type Queries::Query' unless query.is_a?(Query) @nested_query = query.to_hash self end |
#score(score) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/has_parent.rb', line 19 def score(score) raise ArgumentError, 'score must be a boolean' unless !!score == score @score = score self end |
#to_hash ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/has_parent.rb', line 39 def to_hash @query = {} @query.update(parent_type: @parent_type) if @parent_type @query.update(score: @score) if @score @query.update(query: @nested_query) if @nested_query @query.update(inner_hits: @inner_hits) if @inner_hits super end |