aws-amplify / aws-amplify/amplify-data
Get avg of more than one fields in document using search query of elastic-search through GraphQL API
- Dominant language
- TypeScript
- Stars
- 18
- Forks
- 23
- Avg merge
- 26m
- Merged PRs (30d)
- 1
Description
### Is this related to a new or existing framework?
React Native
### Is this related to a new or existing API?
GraphQL API
### Is this related to another service?
Elastic Search or Open Search(new name)
### Describe the feature you'd like to request
I am trying to use searchRatings query to get avg of different fields.
But currently I am limited to get avg of only one of the fields
I have around 50 different columns/fields in table/document in elastic-search
I want to get avg of all the fields which is currently not possible
as you can see I can only select one of the fields from the drop down infront of `field` under `aggregates`
### Describe the solution you'd like
I would like to have the option to get avg of as many fields as I want through GraphQL API provided by Amplify
It may be in the form of array as in case of applying filters ...that we can apply many filters at the same time.
I do not want to make query request 50 times if I want avg of all 50 fields in my document in elastic search.
I have checked elastic search directly through dev tools ... Its is indeed possible to query elastic search directly for more than one field
Here is the screenshot attached where I am getting avg of three different fields at the same time

### Describe alternatives you've considered
Alternatively I am considering to directly query elastic search server using Node package ... bypassing Amplify and GraphQL to have desired results
But I wish to have this feature available through Amplify and GraphQL auto generated queries
### Additional context
_No response_
### Is this something that you'd be interested in working on?
- [ ] 👋 I may be able to implement this feature request
- [ ] ⚠️ This feature might incur a breaking change
Contributor guide
Research direction
Start by tracing the generated searchRatings GraphQL query and its aggregates.field selection into the Amplify data API and Elasticsearch/OpenSearch request. Compare the existing single-field behavior with the multi-field aggregation shown in the issue, then define schema, compatibility, and test expectations for requesting several averages without repeated requests. Done means the API supports multiple average fields and verifies the resulting values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elasticsearch, graphql, react-native
- Domain
- api, data, search
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100