Class: JayAPI::Elasticsearch::QueryBuilder::Aggregations::TopHits
- Inherits:
-
Aggregation
- Object
- Aggregation
- JayAPI::Elasticsearch::QueryBuilder::Aggregations::TopHits
- Defined in:
- lib/jay_api/elasticsearch/query_builder/aggregations/top_hits.rb
Overview
Represents a filter aggregation in Elasticsearch.
Information on this type of aggregation can be found here:
https://www.elastic.co/docs/reference/aggregations/search-aggregations-metrics-top-hits-aggregation
Instance Attribute Summary collapse
-
#_source ⇒ Object
readonly
Returns the value of attribute _source.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#sort ⇒ Object
readonly
Returns the value of attribute sort.
Attributes inherited from Aggregation
Instance Method Summary collapse
-
#clone ⇒ self
A copy of the receiver.
-
#initialize(name, size:, sort: nil, _source: nil) ⇒ TopHits
constructor
rubocop:disable-next Lint/UnderscorePrefixedVariableName -- to match Elasticsearch's name.
-
#to_h ⇒ Hash
The Hash representation of the
Aggregation.
Methods inherited from Aggregation
Constructor Details
#initialize(name, size:, sort: nil, _source: nil) ⇒ TopHits
rubocop:disable-next Lint/UnderscorePrefixedVariableName -- to match Elasticsearch's name
32 33 34 35 36 37 38 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/top_hits.rb', line 32 def initialize(name, size:, sort: nil, _source: nil) super(name) @size = size @sort = sort @_source = _source end |
Instance Attribute Details
#_source ⇒ Object (readonly)
Returns the value of attribute _source.
18 19 20 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/top_hits.rb', line 18 def _source @_source end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
18 19 20 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/top_hits.rb', line 18 def size @size end |
#sort ⇒ Object (readonly)
Returns the value of attribute sort.
18 19 20 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/top_hits.rb', line 18 def sort @sort end |
Instance Method Details
#clone ⇒ self
Returns A copy of the receiver.
41 42 43 44 45 46 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/top_hits.rb', line 41 def clone optional_params = { sort: sort.deep_dup, _source: _source.deep_dup }.compact copy = self.class.new(name, size: size, **optional_params) copy.aggregations = aggregations.clone copy end |
#to_h ⇒ Hash
Returns The Hash representation of the Aggregation.
Properly formatted for Elasticsearch.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/top_hits.rb', line 50 def to_h super do { top_hits: { size: size, sort: sort.deep_dup, _source: _source.deep_dup }.compact } end end |