Where clause for firebase query

5,656 views
Skip to first unread message

Takayuki Suzuki

unread,
Sep 4, 2016, 10:48:03 AM9/4/16
to Firebase Google Group
Hi, I am trying to retrieve data with multiple conditions from firebase. (in swift)

I want to retrieve posts which matches conditions below.
- Posted by someone else.
- Title includes "is"
- Body include "body"
 - Created more than a week ago

I'm doing like below to get posts created by someone else.
databaseRef
           
.child("Posts")
           
.queryOrderedByChild(uid!)
           
.queryEqualToValue(nil)


Is there any ways?
Data structure is like below.

Mike Mcdonald

unread,
Sep 6, 2016, 12:55:45 PM9/6/16
to Firebase Google Group
Takayuki,

What you're looking for here is basically full text search within the Firebase Realtime Database, which isn't something we currently offer. It's likely that you'll want to check out a service like ElasticSearch (using our tool Flashlight) or Algolia, which can help provide these types of advanced queries.

Thanks,
--Mike

Takayuki Suzuki

unread,
Sep 14, 2016, 9:49:41 AM9/14/16
to Firebase Google Group
Hi Mike,

Thank you for your reply.
Sorry, my question was bad.

What I want to do is like below.

databaseRef.child("Posts").where("user_id<>? AND category_id=?", 1, 5).orderBy("created_at DESC")

Is it possible?

Thanks,

Takayuki

2016年9月7日水曜日 1時55分45秒 UTC+9 Mike Mcdonald:

Kato Richardson

unread,
Sep 14, 2016, 11:20:09 AM9/14/16
to Firebase Google Group

You can't do AND'd or OR'd queries. Sorry.

This has been discussed dozens of times in the forum and on Stack Overflow. There is an authoritative answer, with some alternatives, here.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/bc4aed56-997a-49e7-aa25-f62dd1d39617%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Takayuki Suzuki

unread,
Sep 14, 2016, 9:13:56 PM9/14/16
to Firebase Google Group
Thank you for your message.
Do you have plan to add those features (AND OR query) in the future?

Thanks,

Takayuki

2016年9月15日木曜日 0時20分09秒 UTC+9 Kato Richardson:
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages