Hello Guys, How are you all? Hope You all Are Fine. I am using Firestore in my project and I am facing the Following error in my console Uncaught Error in snapshot listener: FirebaseError: no matching index found In javascript. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
How Uncaught Error in snapshot listener: FirebaseError: no matching index found Error Occurs ?
I am using Firebase and when I run the useFireStore Query I am facing the following error in my stack track.
Uncaught Error in snapshot listener: FirebaseError: no matching index found
Here is my query
const query = db.collection('iterations')
.where('courseCode', '==', code)
.orderBy('iterationCode', 'desc')
.limit(1)
.get()
How To Solve Uncaught Error in snapshot listener: FirebaseError: no matching index found Error ?
How To Solve Uncaught Error in snapshot listener: FirebaseError: no matching index found Error?
To Solve Uncaught Error in snapshot listener: FirebaseError: no matching index found Error That’s a known issue with Client SDKs and the Firebase team is working on it. Just use the Firebase Functions Emulator locally with the Admin SDK. Use an existing Firebase project or create a new one for this.
Solution 1
The problem is you must create an index for your “where” and “orderBy” conditions in the indexes column in your cloud firestore.
Solution 2
That’s a known issue with Client SDKs and the Firebase team is working on it. Just use the Firebase Functions Emulator locally with the Admin SDK. Use an existing Firebase project or create a new one for this.
export const getIndexLink = functions.https.onRequest(async (request, response) => {
try {
const snap = const query = db.collection('iterations')
.where('courseCode', '==', code)
.orderBy('iterationCode', 'desc')
.limit(1)
.get()
console.log(snap.size)
response.send( snap.size, "documents matched");
} catch (error) {
console.log(error)
response.send(error.message)
// Error with index creation link
}
});
You can try calling this function in a browser and get the index creation link.
Summery
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also Read