How can I use a GeoQuery to sort by both location and certain value? (Android)

前端 未结 1 1479
小蘑菇
小蘑菇 2021-01-27 03:24

This is a Geoquery for Firestore: https://github.com/imperiumlabs/GeoFirestore-Android But it doesn\'t allow for further sorting. I want to sort by the nearest and most famous

相关标签:
1条回答
  • 2021-01-27 04:05

    Geofire already does something seemingly impossible on Firestore: it performs a range query on two values (lat and lon). It does this by creating a geohash value, which combines the latitude and longitude into a single value, that can be used to select a range of documents that are close to each other.

    To allow additionally select on the range of another field, you'd have to find a way to combine the value of that other field into the Geohash value. It essentially means you have to find a way to express the importance of fame (your additional property) as a function of location (the distance), and compute a single field value based on that. While this may technically possible, I doubt anyone has every done it.

    To learn how filtering on location works (and why adding an extra field is not as simple as it may seem), have a look at:

    • the video of my talk on geofiltering on Firestore
    • Jeff's much more concise Realtime GeoQueries With Firestore video and article
    • Firebase/GeoFire - Most popular item at location
    0 讨论(0)
提交回复
热议问题