invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.64k stars 2.21k forks source link

Firestore Query doesn't work for GeoPoint #561

Closed ziquanc closed 6 years ago

ziquanc commented 6 years ago

Issue

I am using firestore to query nearby location with geopoint, works fine in web sdk but not rnfirebase.

ref.where('location', '>=', lesserGeopoint).where('location', '<=', greaterGeopoint) .get() .then(function (querySnapshot) { if (querySnapshot.empty) { console.log('empty'); } ...

this code always return empty, I did try string fieldPath, works fine too. how can I make this works? thanks.

Environment

Application Target Platform: iOS Development Operating System: macOS Sierra Build Tools: iOS 10 Simulator React Native version: 0.49.3 RNFirebase Version: 3.0.5 Firebase Module: firestore

Salakar commented 6 years ago

@ziquanc please fill out the issue template.

chrisbianca commented 6 years ago

This should now be fixed on the v3.0.x branch and will be included in our next release over the next couple of days.

If you'd like to try the latest code please use the following:

npm install --save https://github.com/invertase/react-native-firebase#v3.0.x

jemise111 commented 6 years ago

@ziquanc Were you able to get that type of query working? For me on the latest version of rnfirebase the query succeeds but my results only respect my latitude range, not my longitude range. I'm wondering if this is a limitation of firestore or I'm doing something wrong, thanks!

kevboh commented 6 years ago

I'm also seeing latitude work but longitude not.

photos commented 6 years ago

My results only respect my latitude range, not my longitude range. Has anyone come up with a solution or workaround?

Ehesp commented 6 years ago

We'll try and get round to testing this. In the mean time, could anyone debug on line https://github.com/invertase/react-native-firebase/blob/master/ios/RNFirebase/firestore/RNFirebaseFirestoreDocumentReference.m#L255 and check what the value of geopoint is (NSDictionary).

jrdzha commented 6 years ago

Anyone know if this was ever fixed on v4.0? I'm on v3.3, and it seems like longitude isn't working, and I'd like to know if it is worth upgrading to v4.0 at this time. Thanks.

jcsena commented 6 years ago

any solution?

stevenyix commented 6 years ago

also interested to know when this will be resolved. i'm having to do an ugly workaround otherwise. does it by chance require creating an index on the geopoint field?

chrisbianca commented 6 years ago

I'm afraid that this is an underlying limitation of Firestore as explained by Frank van Puffelen (puf on Twitter) who's part of the Firebase team: https://stackoverflow.com/a/46608540/5909648

Whilst Firestore allows storing of GeoPoints, querying against them is not officially supported.

I've had a check through our code and we are definitely passing the latitude and longitude through correctly to the native side, and taking a look online it looks like other people using the native libraries are experiencing the same issue: https://stackoverflow.com/a/46920982/5909648 (first comment)

The suggestion is to to filter for longitude on the client side having matched against latitude using Firestore directly.

stevenyix commented 6 years ago

ok. appreciate the update.

georgeMorales commented 5 years ago

Would there be any way to make a query based on the coordinates and be able to paginate the result?