Class: ElasticGraph::GraphQL::Aggregation::Resolvers::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_graph/graphql/aggregation/resolvers/node.rb

Instance Method Summary collapse

Instance Method Details

#aggregated_valuesObject



26
27
28
# File 'lib/elastic_graph/graphql/aggregation/resolvers/node.rb', line 26

def aggregated_values
  @aggregated_values ||= AggregatedValues.new(query.name, bucket, field_path)
end

#countObject



40
41
42
# File 'lib/elastic_graph/graphql/aggregation/resolvers/node.rb', line 40

def count
  bucket.fetch("doc_count")
end

#count_detailObject



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

def count_detail
  @count_detail ||= CountDetail.new(schema_element_names, bucket)
end

#cursorObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elastic_graph/graphql/aggregation/resolvers/node.rb', line 48

def cursor
  # If there's no `key`, then we aren't grouping by anything. We just have a single aggregation
  # bucket containing computed values over the entire set of filtered documents. In that case,
  # we still need a pagination cursor but we have no "key" to speak of that we can encode. Instead,
  # we use the special SINGLETON cursor defined for this case.
  @cursor ||=
    if (key = bucket.fetch("key")).empty?
      DecodedCursor::SINGLETON
    else
      DecodedCursor.new(key)
    end
end

#grouped_byObject



22
23
24
# File 'lib/elastic_graph/graphql/aggregation/resolvers/node.rb', line 22

def grouped_by
  @grouped_by ||= GroupedBy.new(bucket, field_path)
end

#sub_aggregationsObject



30
31
32
33
34
35
36
37
38
# File 'lib/elastic_graph/graphql/aggregation/resolvers/node.rb', line 30

def sub_aggregations
  @sub_aggregations ||= SubAggregations.new(
    schema_element_names,
    query.sub_aggregations,
    parent_queries + [query],
    bucket,
    field_path
  )
end