Appsync cannot sort items by string value with Elasticsearch
See original GitHub issueDescribe the bug
I’m using amplify-cli to generate appsync resolvers with @searchable
directive, but it seems that search resolver cannot sort items by String
value, but it works with AWSDateTime
value.
To Reproduce Example request:
{
searchUsers(sort: {
field: fullName,
direction: asc
}) {
items {
id
fullName
}
}
}
Expected behavior User items sorted by fullName.
Screenshots
Desktop (please complete the following information):
- Using AWS Console
Smartphone (please complete the following information):
- Using AWS Console
Additional context It also happened to my past appsync project.
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = ‘DEBUG’; in your app.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:15 (2 by maintainers)
Top Results From Across the Web
AppSync - query for all items created within a date range?
Which returns all notes that match the UTC time with that string prefix. From which, I have to sort myself using moment.diff(), or...
Read more >Sort search results | Elasticsearch Guide [8.5] | Elastic
Allows you to add one or more sorts on specific fields. Each sort can be reversed as well. The sort is defined on...
Read more >Integrating alternative data sources with AWS AppSync
This function will modify our Redis sorted set by adding or updating restaurant data, specifically latitude and longitude. Generating ...
Read more >API (GraphQL) - Search and result aggregations - Amplify Docs
... get aggregation values, such as sum, average, min, max, terms; retrieve total search result count; sort the search results across one or...
Read more >Finding the nearest locations around you using AWS Amplify
name: String! ... In order to access your Amazon Elasticsearch domain, you can run the ... This will open the AWS AppSync console...
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
@hakimio is right, AWS decided do not overhead it with
fielddata
, resouce:Resource: Elasticsearch docs
I guess AWS team decided to use
keyword
as mentioned in the docsThis query works perfectly:
I haven’t figured out how to make it work from JS side yet
@ShepelievD The velocity templating language allows you to do a check like if string field array contains sort field, add “.keyword” postfix, otherwise leave it as it is.