firebase / geofire-java

GeoFire for Java - Realtime location queries with Firebase
MIT License
670 stars 271 forks source link

Query for recently added locations first #37

Closed shivarajp closed 8 years ago

shivarajp commented 8 years ago

Is there anyway I can get the recently added locations first rather than old - new locations. In my case I have thousands of entries so every time I query I have to go through all callbacks and then compare and find out recently added 10 locations out of that, its a huge burden on performance, is there any way this can be done? Is it possible to store time with location object in geofire node.

samtstern commented 8 years ago

This is not possible with the current GeoFire API. Have you considered keeping a list of recently added locations elsewhere in the Realtime Database so you can query it easily?

shivarajp commented 8 years ago

Unfortunately that won't work in my case, I want to show recently added posts around user like 1km radius so never know which post is recent to which location so I have to get the recently added post keys for users current location.

On Fri 22 Jul, 2016 9:38 pm Sam Stern, notifications@github.com wrote:

This is not possible with the current GeoFire API. Have you considered keeping a list of recently added locations elsewhere in the Realtime Database so you can query it easily?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/firebase/geofire-java/issues/37#issuecomment-234585807, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMGknhSo0yOJIVT9s2mBkPsZmy8u-jNks5qYOrhgaJpZM4JSpzv .

samtstern commented 8 years ago

Ah ok well I think in that case getting all of the posts within 1km and then doing client-side filtering is going to be your only option with the current GeoFire capabilities.

shivarajp commented 8 years ago

Yeah, but I am scared of locations which may have 100's of thousands of posts in that case app will freeze , it will take forever to load all the posts. At least a fetch complete listener would have worked because geofire is super fast once it finished getting all the locations then I can at least load few from the bottom of the list & by the way right now in what order it returns locations?

samtstern commented 8 years ago

@jwngr do you know anything internal that would enable this sort of behavior? Maybe by forking?

jwngr commented 8 years ago

You'll have to manage this yourself. You could have different GeoFire indexes based on time ranges instead of just one big GeoFire index. But there is no built-in way to do this with GeoFire, mainly because Firebase only supports querying on a single child.

shivarajp commented 8 years ago

Yes, I ended up doing that only, I am using country code and today's date as the key so every one read write at same for that day. It's just a work around but not sure how it scales.

On Sat, Jul 23, 2016 at 5:19 AM, Jacob Wenger notifications@github.com wrote:

You'll have to manage this yourself. You could have different GeoFire indexes based on time ranges instead of just one big GeoFire index. But there is no built-in way to do this with GeoFire, mainly because Firebase only supports querying on a single child.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/firebase/geofire-java/issues/37#issuecomment-234683431, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMGkmyLuJAxUWBO2XYv_bpIqJumJGqPks5qYVcdgaJpZM4JSpzv .

Shivaraj Patil | Triveous | shivrajp130@gmail.com urbaddy@gmail.com | +91-7353489699