Query Firestore on Mobile: Query Builder and Quick Search
Most Firestore problems start with a question. Which orders are still pending? Which users signed up this week? Which documents have a missing field? On a laptop you would write code or click through the console. On your phone, you want an answer in a few taps.
This guide walks through querying Firestore from Android using FireAdmin, a free app on Google Play. It covers the visual query builder, short text queries, saved queries, and searching across collections. FireAdmin is an independent app by Smartrix Labs and is not affiliated with Google or Firebase.
How Firestore queries work (the short version)
A Firestore query looks at one collection and returns the documents that match your filters. You can add a sort order and a limit. Unlike SQL, Firestore does not join tables, and it only supports certain combinations of filters.
The operators FireAdmin supports match the common Firestore ones:
| Operator | Use it to find |
|---|---|
== / != | Exact matches or everything except a value |
>, >=, <, <= | Numbers and dates in a range |
| Array contains | Documents whose array field holds one value |
| Array contains any | Documents whose array holds any of several values |
| Where in | Documents whose field equals any of a list of values |
You can also order results ascending or descending and set a limit, which is a good idea on large collections so you do not load more than you need.
Method 1: the visual query builder
- Open FireAdmin and choose your project.
- Go to the Query area and enter the collection name.
- Tap to add a filter. Pick the field, the operator and the value.
- Add more filters if you need them.
- Optionally set Order By and a Limit.
- Run the query and read the results as a list. Tap a result to open the document.
The builder is the safest choice when you are tired or in a hurry, because you pick from menus rather than typing syntax.
Method 2: type a short text query
If you know what you want, you can type a plain-text query instead. FireAdmin understands short forms like these:
age > 25status = activeprice < 100 order by name limit 10createdAt > 2024-01-01 order by date desc
This is faster than the builder once you are used to it, and it is easy to tweak: change one number and run it again.
Save the queries you use again
If you check the same thing every week, such as pending orders or unverified accounts, save the query. FireAdmin lets you keep saved queries and organise them into folders, for example Production, Development and Testing. There are also prebuilt query templates for common jobs.
A tip: name saved queries by what they answer, such as "Orders pending over 3 days", not by the collection name. Six months from now, you will thank yourself.
Search when you do not know the collection
Sometimes you have a value but no idea where it lives: an email address, an order number, a name. Global search looks for a value across all your collections. You can choose the match type: contains, exact, starts with or ends with. Start with "exact" for IDs and emails, and "contains" for names.
Global search reads documents to look for matches, so on a very large database it can use many reads. Reads are billed by Firestore, so on big projects prefer a targeted query on a known collection when you can.
Common reasons a query returns nothing
- Wrong type. Searching for
25will not match a field that holds the text"25". - Wrong collection or project. Check the project name and the exact collection spelling. Names are case sensitive.
- Missing index. Some combinations of filters and sort orders need a composite index in Firestore. If a query needs one, Firestore reports it, and you can create the index in your project.
- Field absent. Documents that do not contain the field will not match a filter on it.
Keep an eye on costs when you query
Each document a query returns counts as a read in Firestore billing. A query with no limit against a huge collection can read a lot of documents. Use filters and limits, and check the current allowances on the Firebase pricing page rather than guessing. FireAdmin also has a usage dashboard that shows reads, writes and deletes over time, so you can see the effect of your own checking.
You can get FireAdmin on Google Play and try these queries on a staging project first.
FAQ
Can I save queries in FireAdmin?
Yes. You can save queries and group them in folders, and there are templates for common operations.
Which filter operators are supported?
Equals, not equals, greater than, greater than or equal, less than, less than or equal, array contains, array contains any, and where in. You can also order results and set a limit.
Can I search every collection at once?
Yes. Global search looks for a value across all collections, with contains, exact, starts with and ends with matching.
Do queries cost money?
Firestore bills reads, and each document returned by a query is a read. Use limits and check the Firebase pricing page for current free allowances.