Class: JayAPI::Elasticsearch::QueryBuilder::Aggregations::Filter
- Inherits:
-
Aggregation
- Object
- Aggregation
- JayAPI::Elasticsearch::QueryBuilder::Aggregations::Filter
- Defined in:
- lib/jay_api/elasticsearch/query_builder/aggregations/filter.rb
Overview
Represents a filter
aggregation in Elasticsearch. Information on this type of aggregation can be found here: www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
Instance Attribute Summary
Attributes inherited from Aggregation
Instance Method Summary collapse
-
#clone ⇒ self
A copy of the receiver.
-
#initialize(name) {|The| ... } ⇒ Filter
constructor
A new instance of Filter.
-
#to_h ⇒ Hash
The Hash representation of the
Aggregation
.
Methods inherited from Aggregation
Constructor Details
#initialize(name) {|The| ... } ⇒ Filter
Returns a new instance of Filter.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/filter.rb', line 22 def initialize(name, &block) super(name) unless block raise(::JayAPI::Elasticsearch::QueryBuilder::Aggregations::Errors::AggregationsError, "The #{self.class.name.demodulize} aggregation must be initialized with a block") end block.call(query) end |
Instance Method Details
#clone ⇒ self
Returns A copy of the receiver.
34 35 36 37 38 39 40 41 42 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/filter.rb', line 34 def clone # rubocop:disable Lint/EmptyBlock (The query will be assigned later) copy = self.class.new(name) {} # rubocop:enable Lint/EmptyBlock copy.query = query.clone copy.aggregations = aggregations.clone copy end |
#to_h ⇒ Hash
Returns The Hash representation of the Aggregation
. Properly formatted for Elasticsearch.
46 47 48 49 50 51 52 |
# File 'lib/jay_api/elasticsearch/query_builder/aggregations/filter.rb', line 46 def to_h super do { filter: query.to_h } end end |