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:
- Created 5 years ago
- Reactions:5
- Comments:10 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
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
*-helpchannels for those types of questions.