What is a common limitation of Firebase Firestore queries?
Firestore queries can only filter on indexed fields and support simple logical operations. Complex queries like OR across different fields or full-text search are not directly supported.
Click to reveal answer
intermediate
Why can't Firebase Firestore perform 'OR' queries across different fields directly?
Firestore indexes each field separately and does not support combining multiple fields with OR logic in a single query, to keep queries fast and scalable.
Click to reveal answer
beginner
What is a workaround for performing 'OR' queries in Firebase Firestore?
Run multiple queries for each condition separately and merge the results in your app code.
Click to reveal answer
intermediate
How can you handle full-text search limitations in Firebase Firestore?
Use an external search service like Algolia or Elasticsearch, syncing your Firestore data to it for advanced search capabilities.
Click to reveal answer
beginner
What is a limitation related to Firestore query result size?
Firestore limits query results to 1MB of data per query. Large datasets require pagination or filtering to reduce data size.
Click to reveal answer
Which of the following is NOT a direct limitation of Firebase Firestore queries?
ACannot perform OR queries across different fields in one query
BCannot filter on non-indexed fields
CQuery results limited to 1MB of data
DCannot sort results
✗ Incorrect
Firestore supports sorting query results, so option C is not a limitation.
What is a common workaround to perform OR queries in Firestore?
AUse a single complex query with OR logic
BUse SQL joins
CRun multiple queries and merge results in the app
DUse Firestore's built-in OR operator
✗ Incorrect
Firestore does not support OR queries directly, so running multiple queries and merging results is the workaround.
How can you add full-text search capabilities to Firestore data?
AUse Firestore's native full-text search
BUse an external search service like Algolia
CUse Firestore's OR queries
DUse Firestore's array-contains-any filter
✗ Incorrect
Firestore does not support full-text search natively; external services like Algolia provide this feature.
What happens if a Firestore query returns more than 1MB of data?
AThe query fails or returns partial data
BThe query compresses data
CThe query returns all data without limit
DThe query automatically paginates
✗ Incorrect
Firestore limits query results to 1MB; exceeding this causes failure or partial data return.
Which field must be indexed to be used in Firestore queries?
AAny field used in filters or sorting
BOnly fields with numeric data
COnly fields with string data
DNo fields need indexing
✗ Incorrect
Firestore requires indexing on any field used in filters or sorting for queries to work.
Explain the main query limitations in Firebase Firestore and how you can work around them.
Think about what Firestore can and cannot do with queries and how to handle those cases.
You got /4 concepts.
Describe how to implement full-text search for Firestore data despite its limitations.
Consider combining Firestore with specialized search tools.
You got /4 concepts.
Practice
(1/5)
1. What is a common limitation when using Firebase queries with multiple filters?
easy
A. You can only apply range filters on a single field at a time.
B. You can apply unlimited filters on any fields without restrictions.
C. Firebase automatically merges all filters without any index setup.
D. You cannot use any filters with Firebase queries.
Solution
Step 1: Understand Firebase query filter limits
Firebase allows only one range filter (like greater than or less than) on a single field per query to maintain performance.
Step 2: Recognize the impact on multiple filters
Applying multiple range filters on different fields is not allowed, so you must design queries accordingly.
Final Answer:
You can only apply range filters on a single field at a time. -> Option A
Quick Check:
Range filters limited to one field = B [OK]
Hint: Only one range filter per query field allowed [OK]
Common Mistakes:
Thinking multiple range filters on different fields are allowed
Assuming no index setup is needed for filters
Believing unlimited filters can be combined
2. Which of the following is the correct syntax to add a filter for documents where the field age is greater than 18 in Firebase Firestore?
easy
A. db.collection('users').filter('age' > 18)
B. db.collection('users').where('age', '>', 18)
C. db.collection('users').where('age' => 18)
D. db.collection('users').query('age', '>', 18)
Solution
Step 1: Recall Firestore query syntax
The correct method to filter documents is using where(field, operator, value).
Step 2: Match the correct operator and syntax
The operator for greater than is '>', so where('age', '>', 18) is correct.
Final Answer:
db.collection('users').where('age', '>', 18) -> Option B
Quick Check:
Use where with operator '>' = A [OK]
Hint: Use where(field, operator, value) for filters [OK]
B. The equality filter must come after range filters.
C. The collection name is incorrect.
D. You cannot have two range filters on different fields in one query.
Solution
Step 1: Identify filters used
The query has one equality filter on 'status' and two range filters on 'total' and 'date' fields.
Step 2: Recall Firestore query limitations
Firestore allows only one range filter on a single field per query, so having range filters on two different fields causes an error.
Final Answer:
You cannot have two range filters on different fields in one query. -> Option D
Quick Check:
Only one range filter field allowed = D [OK]
Hint: Only one range filter field per query allowed [OK]
Common Mistakes:
Thinking order of filters matters
Assuming Firestore can't filter by date
Believing collection name causes this error
5. You need to query a Firestore collection for documents where status is 'active', priority is greater than 5, and createdAt is after '2023-01-01'. How can you work around Firestore's query limitations to get this data?
hard
A. Create a composite field combining priority and createdAt and filter on it.
B. Use a single query with all three filters combined directly.
C. Run two separate queries: one filtering by status and priority, another by status and createdAt, then merge results in code.
D. Use Firestore's built-in full-text search to handle all filters.
Solution
Step 1: Understand Firestore query limits
Firestore does not allow multiple range filters on different fields in a single query.
Step 2: Apply workaround using multiple queries
Run two queries: one filtering by status and priority, another by status and createdAt, then combine results in your application code.
Final Answer:
Run two separate queries: one filtering by status and priority, another by status and createdAt, then merge results in code. -> Option C
Quick Check:
Multiple queries merge workaround = A [OK]
Hint: Split complex filters into multiple queries and merge results [OK]
Common Mistakes:
Trying to combine all filters in one query causing errors
Assuming composite fields solve all filter issues
Expecting Firestore to support full-text search natively
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.