question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Aggregation operation on DynamoDB+ElasticSearch

See original GitHub issue

** Which Category is your question related to? ** GraphQL API

** What AWS Services are you utilizing? ** AppSync, DynamoDB, ElasticSearch

** Provide additional details e.g. code snippets ** Let’s assume I have defined the model in my Amplify app:

type Item @model @searchable {
  id: ID!
  inventoryType: String!
  itemName: String!
  price: Int
}

I want to do things like:

SELECT DISTINCT(inventoryType) FROM Item;
SELECT SUM(price) FROM Item;
SELECT SUM(price) FROM Item WHERE inventoryType="xxx";

As they are complex query, I want to utilize ElasticSearch. The graphql query generated by amplify codegen is:

export const searchItems = `query SearchItems(
  $filter: SearchableItemFilterInput
  $sort: SearchableItemSortInput
  $limit: Int
  $nextToken: Int
) {
  searchItems(
    filter: $filter
    sort: $sort
    limit: $limit
    nextToken: $nextToken
  ) {
    items {
      id
      inventoryType
      itemName
      price
    }
    nextToken
  }
}
`;

My questions are:

  • Can I do the above operations by utilizing the generated query?
  • If yes, what are the queries (filter) look like?
  • If not, what is the right way to achieve this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
krsnaacommented, Jul 26, 2019

This seems like this is a valid questions re: aggregations on the GQL API. My guess is that it will require a custom VTL script. An official response/code-snippet would be appreciated.

0reactions
github-actions[bot]commented, Jan 27, 2022

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use aggregate functions in Amazon Dynamodb
DynamoDB is a NoSQL database and therefore is very limited on how you can query data. It is not possible to perform aggregations...
Read more >
Aggregating Data through DynamoDB Streams
Elasticsearch supports search queries and aggregation. Compared to saving aggregated data into another DynamoDB table, this approach may be ...
Read more >
Using Global Secondary Indexes for materialized aggregation ...
The Lambda function can aggregate and group the downloads by songID and update the top-level item, Partition-Key=songID , and Sort-Key=Month .
Read more >
Aggregate Functions | Elasticsearch Guide [8.5]
Functions for computing a single result from a set of input values. Elasticsearch SQL supports aggregate functions only alongside grouping (implicit or explicit) ......
Read more >
Search Your DynamoDB Data with Amazon Elasticsearch ...
Learn the joint power of Amazon Elasticsearch Service and DynamoDB and how to set up your DynamoDB tables and streams to replicate your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found