Module: ElasticGraph::GraphQL::Aggregation::TermGrouping
- Included in:
- FieldTermGrouping, ScriptTermGrouping
- Defined in:
- lib/elastic_graph/graphql/aggregation/term_grouping.rb
Overview
Represents a grouping on a term. For the relevant Elasticsearch docs, see: www.elastic.co/guide/en/elasticsearch/reference/7.12/search-aggregations-bucket-terms-aggregation.html www.elastic.co/guide/en/elasticsearch/reference/7.12/search-aggregations-bucket-composite-aggregation.html#_terms
Constant Summary collapse
- INNER_META =
{"key_path" => ["key"], "merge_into_bucket" => {}}
Instance Method Summary collapse
- #composite_clause(grouping_options: {}) ⇒ Object
- #encoded_index_field_path ⇒ Object
- #inner_meta ⇒ Object
- #key ⇒ Object
- #non_composite_clause_for(query) ⇒ Object
Instance Method Details
#composite_clause(grouping_options: {}) ⇒ Object
28 29 30 |
# File 'lib/elastic_graph/graphql/aggregation/term_grouping.rb', line 28 def composite_clause(grouping_options: {}) {"terms" => terms_subclause.merge()} end |
#encoded_index_field_path ⇒ Object
24 25 26 |
# File 'lib/elastic_graph/graphql/aggregation/term_grouping.rb', line 24 def encoded_index_field_path @encoded_index_field_path ||= FieldPathEncoder.join(field_path.filter_map(&:name_in_index)) end |
#inner_meta ⇒ Object
44 45 46 |
# File 'lib/elastic_graph/graphql/aggregation/term_grouping.rb', line 44 def INNER_META end |
#key ⇒ Object
20 21 22 |
# File 'lib/elastic_graph/graphql/aggregation/term_grouping.rb', line 20 def key @key ||= FieldPathEncoder.encode(field_path.map(&:name_in_graphql_query)) end |
#non_composite_clause_for(query) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/elastic_graph/graphql/aggregation/term_grouping.rb', line 32 def non_composite_clause_for(query) clause_value = work_around_elasticsearch_bug(terms_subclause) { "terms" => clause_value.merge({ "size" => query.paginator.desired_page_size, "show_term_doc_count_error" => query.needs_doc_count_error }) } end |