Class: ElasticGraph::GraphQL::Aggregation::Computation

Inherits:
Data
  • Object
show all
Defined in:
lib/elastic_graph/graphql/aggregation/computation.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#computed_index_field_nameObject (readonly)

Returns the value of attribute computed_index_field_name

Returns:

  • (Object)

    the current value of 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

#detailObject (readonly)

Returns the value of attribute detail

Returns:

  • (Object)

    the current value of detail



21
22
23
# File 'lib/elastic_graph/graphql/aggregation/computation.rb', line 21

def detail
  @detail
end

#source_field_pathObject (readonly)

Returns the value of attribute source_field_path

Returns:

  • (Object)

    the current value of 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

#clauseObject



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