Class: Elasticated::TopHitsAggregation
- Inherits:
-
Aggregation
- Object
- Aggregation
- Elasticated::TopHitsAggregation
- Defined in:
- lib/elasticated/aggregations/top_hits_aggregation.rb
Instance Attribute Summary collapse
-
#query ⇒ Object
Returns the value of attribute query.
Attributes inherited from Aggregation
#alias_name, #extra_params, #field
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(name, *args, &block) ⇒ TopHitsAggregation
constructor
A new instance of TopHitsAggregation.
- #parse(response) ⇒ Object
Methods inherited from Aggregation
Methods included from Mixins::Inspectionable
Methods included from Mixins::BlockEvaluation
Methods included from Mixins::Clonable
Constructor Details
#initialize(name, *args, &block) ⇒ TopHitsAggregation
Returns a new instance of TopHitsAggregation.
6 7 8 9 10 |
# File 'lib/elasticated/aggregations/top_hits_aggregation.rb', line 6 def initialize(name, *args, &block) super self.query = Query.new query.evaluate block end |
Instance Attribute Details
#query ⇒ Object
Returns the value of attribute query.
4 5 6 |
# File 'lib/elasticated/aggregations/top_hits_aggregation.rb', line 4 def query @query end |
Instance Method Details
#build ⇒ Object
12 13 14 |
# File 'lib/elasticated/aggregations/top_hits_aggregation.rb', line 12 def build { top_hits: query.build_for_top_hits } end |
#parse(response) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/elasticated/aggregations/top_hits_aggregation.rb', line 16 def parse(response) # total = response['hits']['total'] # max_score = response['hits']['max_score'] # hits = response['hits']['hits'].map{ |hit| Document.parse hit } # HitsInfo.new total, max_score, hits response['hits']['hits'].map{ |hit| Document.parse hit } end |