Skip to content Skip to sidebar Skip to footer

Uncaught (in Promise) Error: The Query Requires An Index

I get this error once I added the Where method, but it works without the Where clause. In collection every document has Boolean called 'status'. db.firestore().collection('jobs'

Solution 1:

Since you're querying on two fields (status and createDate), there needs to be a composite index on those two fields. Indices on individual fields are automatically created, but composite indexes are only created when you ask for them.

The error message should contain a link directly to the console to complete that task. If that's not the case, you can create it here.

Solution 2:

Firestore query on more than two fields requires a composite index on that two filed.

So you have to create composite index status and createDate.You will get the error like following when you don't have an index.

ERROR Error: The query requires an index. You can create it here: https://console.firebase.google.com/project/admin-e8a7b/database/firestore/indexes?create_index=EgR0ZW1wGgcKA3VpZBACGg0KCXN0YXJ0ZWRBdBADGgwKCF9fbmFtZV9fEAMat newFirestoreError(vendor.bundle.js:19925)

So when you click this link in error index will be created automatically.

You can also manually create index from firebase console

To combine the equality operator (==) with a range comparison (<, <=, >, or >=), make sure to create a custom index.

Post a Comment for "Uncaught (in Promise) Error: The Query Requires An Index"