Class: ElasticGraph::GraphQL::Aggregation::Computation
- Inherits:
-
Data
- Object
- Data
- ElasticGraph::GraphQL::Aggregation::Computation
- Defined in:
- lib/elastic_graph/graphql/aggregation/computation.rb
Overview
Represents some sort of aggregation computation (min, max, avg, sum, etc) on a field. For the relevant Elasticsearch docs, see: www.elastic.co/guide/en/elasticsearch/reference/7.12/search-aggregations-metrics-avg-aggregation.html www.elastic.co/guide/en/elasticsearch/reference/7.12/search-aggregations-metrics-max-aggregation.html www.elastic.co/guide/en/elasticsearch/reference/7.12/search-aggregations-metrics-min-aggregation.html www.elastic.co/guide/en/elasticsearch/reference/7.12/search-aggregations-metrics-sum-aggregation.html
Instance Attribute Summary collapse
-
#computed_index_field_name ⇒ Object
readonly
Returns the value of attribute computed_index_field_name.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#source_field_path ⇒ Object
readonly
Returns the value of attribute source_field_path.
Instance Method Summary collapse
Instance Attribute Details
#computed_index_field_name ⇒ Object (readonly)
Returns the value of attribute computed_index_field_name
21 22 23 |
# File 'lib/elastic_graph/graphql/aggregation/computation.rb', line 21 def computed_index_field_name @computed_index_field_name end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail
21 22 23 |
# File 'lib/elastic_graph/graphql/aggregation/computation.rb', line 21 def detail @detail end |
#source_field_path ⇒ Object (readonly)
Returns the value of attribute source_field_path
21 22 23 |
# File 'lib/elastic_graph/graphql/aggregation/computation.rb', line 21 def source_field_path @source_field_path end |
Instance Method Details
#clause ⇒ Object
32 33 34 35 |
# File 'lib/elastic_graph/graphql/aggregation/computation.rb', line 32 def clause encoded_path = FieldPathEncoder.join(source_field_path.filter_map(&:name_in_index)) {detail.function.to_s => {"field" => encoded_path}} end |
#key(aggregation_name:) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/elastic_graph/graphql/aggregation/computation.rb', line 24 def key(aggregation_name:) Key::AggregatedValue.new( aggregation_name: aggregation_name, field_path: source_field_path.map(&:name_in_graphql_query), function_name: computed_index_field_name ).encode end |