简体   繁体   中英

Getting nodes from Firebase Database with a complex query in Android Studio

I've got a Firebase Realtime Database, with this sample structure 基本节点结构

I need to create filters, so I can grab all nodes that, ie, costs between $100 and $400, not farther away than 60 miles from my current location, and whose startDate is not before today. Or any kind of combination of those filters (cost from, cost to, distance, start date from, start date to).

Is there any efficient way of storing this data so all the filtering can occur on the server side?

I know I can make an .orderByChild( "cost" ).startAt(100).endAt(400) , and then iterate through the datasnapshot on the client side, but I don't think it's elegant or efficient when the database grows.

Imagine bringing millions of nodes just to show the 3 or 4 that fulfills all filters.

I've been doing a lot of research (believe me), but it's so hard for me to still grab the taste of it. I've been raised in a SQL shell, and those querys used to be my ABC, I just can't stand the idea of things getting so annoyingly ugly, but it must be me.

Anyone with more experience with these NO-SQL databases can give me a hand out here? It has to be Firebase Realtime Database, not the Cloud Firestore.

I think that in the realtime - database you can't do that in a server side with a simple query. I know that with dataSnapshot u'll take all the data and choose what you want, but as you told, if milion of nodes...it become very hard. I think that you should use SQL for this type of application. This is my opinion, i'm waiting for other answer at this post :D

Sorry for the answer but i can't comment ;(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM