Is there a way to search any tag in Firebase?
Like if I want to search for string "123" and get all the for that.
Is there a way to search any tag in Firebase?
Like if I want to search for string "123" and get all the for that.
You would need to be "in" tag 16932 to search for tag 123.
You can set your projectBucket to an empty text block, this will return everything in your firebase project as a json, which you can then search using dictionaries blocks. (Note: this could prove expensive in production!)
See this article: https://firebase.google.com/docs/database/android/structure-data
You would have to set up indexing of your data.
Indexing Firebase Data:
https://firebase.google.com/docs/database/security/indexing-data
No blocks are available for querying Firebase data with indexing, you have to use the web component (and/or a webviewer if with authentication) and Firebase's REST api.
All that said, indexing probably won't work for your data structure, because there are no common tags.
Yeah, I know. Fetching all tags will be difficult with the growing size of DB. That's why I want to know, if there is a way to search like you do in SQL with WHERE clause.
In the example, it is not shown, but the string 123 could be at multiple places i.e. under other tags like 17451, or 13147.
If there are multiple "123"s in the db then get Firebase to do the indexing work.
I may have an an example you can follow....
In simplest terms, this should work....
assuming you have no authentication rules setup (so data is read/write=true)
say your data structure is like this:
users <<top level project bucket
|-167981
|-234:"hello"
|-176584
|-123:"goodbye"
|-158394
|-123:"goodmorning"
|-167834
|-345:"goodevening"
and you want to return the data associated with the tags 123.
You need to go into the rules and set this:
"users": {
".read": true,
".write": true,
".indexOn": "123"
},
in your rules.
Then, using the web component call:
https://<PROJECTID>.firebaseio.com/users.json?orderBy="123"
(you can test this in a computer web browser as well)
you may need to use:
https://<PROJECTID>.firebaseio.com/users.json?orderBy=%22123%22
or add a encodeUri block.
ALL the data is returned for the tags that contain 123! Firebase does not return tag level data, it returns the whole lot. You should get back something like:
{ "176584" : ["123" : "goodbye"], "158394" : ["123" : "goodmorning"] }
Good luck!