Class: Elasticated::FilterAggregation
- Inherits:
-
Aggregation
- Object
- Aggregation
- Elasticated::FilterAggregation
- Includes:
- Subaggregated
- Defined in:
- lib/elasticated/aggregations/filter_aggregation.rb
Instance Attribute Summary collapse
-
#_evaluator ⇒ Object
Returns the value of attribute _evaluator.
-
#_filter_name ⇒ Object
Returns the value of attribute _filter_name.
-
#compact ⇒ Object
Returns the value of attribute compact.
-
#include_count ⇒ Object
Returns the value of attribute include_count.
Attributes included from Subaggregated
Attributes inherited from Aggregation
#alias_name, #extra_params, #field
Instance Method Summary collapse
- #accept_visitor(visitor) ⇒ Object
- #build ⇒ Object
- #default_name ⇒ Object
-
#initialize(filter_name, *args, &block) ⇒ FilterAggregation
constructor
A new instance of FilterAggregation.
- #parse(response) ⇒ Object
Methods included from Subaggregated
Methods inherited from Aggregation
Methods included from Clonable
Methods included from BlockEvaluation
Constructor Details
#initialize(filter_name, *args, &block) ⇒ FilterAggregation
Returns a new instance of FilterAggregation.
7 8 9 10 11 12 13 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 7 def initialize(filter_name, *args, &block) self._filter_name = filter_name super self.compact = extra_params.delete(:compact) { false } self.include_count = extra_params.delete(:include_count) { true } initialize_subaggregations FilterAggregationEvaluator.new, &block end |
Instance Attribute Details
#_evaluator ⇒ Object
Returns the value of attribute _evaluator.
5 6 7 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 5 def _evaluator @_evaluator end |
#_filter_name ⇒ Object
Returns the value of attribute _filter_name.
5 6 7 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 5 def _filter_name @_filter_name end |
#compact ⇒ Object
Returns the value of attribute compact.
5 6 7 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 5 def compact @compact end |
#include_count ⇒ Object
Returns the value of attribute include_count.
5 6 7 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 5 def include_count @include_count end |
Instance Method Details
#accept_visitor(visitor) ⇒ Object
39 40 41 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 39 def accept_visitor(visitor) visitor.visit_filter_aggregation(self) end |
#build ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 19 def build # _subaggregations is a FilterAggregationEvaluator, so... conditions = _subaggregations.build_conditions body = { filter: conditions } body.merge! build_subaggregations body end |
#default_name ⇒ Object
15 16 17 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 15 def default_name _filter_name end |
#parse(response) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/elasticated/aggregations/filter_aggregation.rb', line 27 def parse(response) count = response['doc_count'] if _subaggregations.empty? compact ? count : { 'count' => count } else parse_subaggregations(response).tap do |h| h['count'] = count if include_count end end end |