'Composite index firestore
I am using two different queries to order my data and putting a where clause. I need a composite index. I am also using limitToLast
const tradesRef = firebase
.firestore()
.collection("trades")
.orderBy("time", "asc")
.where("type", "==", "fiveMinutes")
.limit(15);
I have created a composite index such as:

I am still getting this error:
Solution 1:[1]
The fields indexed seem to be correct but you are not running a collection group query so have you tried setting the query scope to just "Collection" instead of "Collection group"?
Also try deleting current index and creating new index directly using the link in error.
Solution 2:[2]
As mentioned in the stackoverflow Answer :
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.
For more information related to how firestore manages indexes, you can refer to the documentation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharmaraj |
| Solution 2 | Divyani Yadav |

