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.
Attributes included from Subaggregated
Attributes inherited from Aggregation
#alias_name, #extra_params, #field
Instance Method Summary collapse
- #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 Mixins::Inspectionable
Methods included from Mixins::BlockEvaluation
Methods included from Mixins::Clonable
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 } raise "The 'include_count' parameter was removed in filter aggregations" if extra_params.has_key? :include_count 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 |
Instance Method Details
#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 compact && _subaggregations.empty? count else raise "Compact is not a valid parameter on a subaggregated 'filter' aggregation" if compact body = { 'count' => count } body.merge! parse_subaggregations(response) body end end |