-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filters doesn't return any data when using numbers. #13371
Comments
Good morning @cwomack, any luck on this one? |
Hey @cwomack, did you have any chance to take a look at this one? |
Hi, @fimbres 👋 Sorry for the delayed response. Thank you for raising this issue! I will be reproducing this issue and report back soon to mark as a bug or explain any findings |
No worries @chrisbonifacio, thank you so much for helping! |
Hi @fimbres I deployed the same schema but I don't think I ran into any issues while trying to query and filter using numbers. Here's my first query: const { data } = await client.graphql({
query: listAffiliates,
variables: {
filter: {
and: [
{
lat: {
between: [0, 40],
},
},
{
lng: {
between: [-300, -100],
},
},
],
},
},
}); and the result: I changed the lat: {
between: [0, 20],
}, and the result was no data, as expected: Also doing eq seems to work: const { data } = await client.graphql({
query: listAffiliates,
variables: {
filter: {
and: [
{
lat: {
eq: 36.77676,
},
},
{
lng: {
eq: -115.56526,
},
},
],
},
},
}); Same result as first query. Can you share more details about the values you're using to filter for records? |
Interesting, yes as I said previously this is my data
If I filter this data based either on lat or lng properties (Float) I don't get any data back, even doing eq or between statements. I don't know if this can be related with my migration from string to float field type (because previously both fields were String types) maybe in the migration process something was missing? Should I try deleting this two fields and then reading them with the correct field type? |
Or perhaps it's something related with the @searchable tag that previously I added to the Affiliate model
|
@chrisbonifacio I have an update, now I'm able to see one of the two records coming back from the numeric filter, but as you can see both of the records have the same cords. Do you have any idea on why is this happening?
data returning: |
Can you check the network activity in your browser, search for the |
also do you still have searchable enabled? what is the current schema you're using? There is an issue I remember regarding OpenSearch and unexpected results with floats in particular: aws-amplify/amplify-category-api#866 Relevant takeaways from the reproduction of that issue:
|
Sure thing, this is the payload:
|
Right now it's enabled, this is the model:
But I'm not using the searchable query, I'm using a custom query. in my OpenSearch instance I don't have any record. I think it's because I did not added any Affiliates record after this instance was created. if I remove the @searchable tag from the model, should I still be able to query based on lat & lng? |
@chrisbonifacio I just removed @searchable but nothing changed |
Any idea on this one @chrisbonifacio ? |
Hi @fimbres apologies for the wait. We haven't been able to reproduce this issue internally. If you're still experiencing this issue I would try testing the same query in the AppSync console and see if you get the same behavior and also in the DynamoDB console. This would rule out whether it's an issue with Amplify's resolvers, library, or if the issue is occurring at the database level. Might also be worth trying to reproduce on a fresh project. |
@fimbres one other possible thing that could be preventing one record from being returned and not another that should match the filter expression, is a difference in authorization rules or owners. Can you share what authorization rules might be on the model to confirm? Can you also check the response for a |
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you. Thank you! |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
Amplify CLI
Environment information
Describe the bug
I'm trying to get all the records in my db filtering by lat and lng, (Float fields) I have a range for each field (lat, lng)
This is my query statement:
Even doing this doesn't seems to work:
My data without any filtering is this one so it should work:
Expected behavior
Filter the records in my db in order to get the nearest to the user.
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
Iphone 15 pro Simulator
Mobile Operating System
IOS 17.4
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: