Module: ElasticGraph::GraphQL::Aggregation::TermGrouping

Included in:
FieldTermGrouping, ScriptTermGrouping
Defined in:
lib/elastic_graph/graphql/aggregation/term_grouping.rb

Overview

Constant Summary collapse

INNER_META =
{"key_path" => ["key"], "merge_into_bucket" => {}}

Instance Method Summary collapse

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(grouping_options)}
end

#encoded_index_field_pathObject



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_metaObject



44
45
46
# File 'lib/elastic_graph/graphql/aggregation/term_grouping.rb', line 44

def inner_meta
  INNER_META
end

#keyObject



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