I'm getting the above error when running the following query. I've not seen it before, can't find any documentation about it, and I'm not doing anything unusual or anything I've not done before. Can anyone shed any light on it, please?
const getUserProjects = async () => {
return await useFireStore
.collection('projects')
.where('paid','==',true)
.where('ownerId','==', `${currentUser.uid}`)
.orderBy('createdAt', 'desc')
.onSnapshot(snapshot => {
let projects = [];
snapshot.forEach(doc => {
projects.push({...doc.data(), id: doc.id })
});
setUserProjects(projects);
});
};
It is a 'new' query in that I've just added it to the code, so I might expect the error in the console that gives a link for a new posite index to be created or whatever it's called, but I'm just getting this instead:
EDIT: I have tried manually creating an Index, but I still get the same error. I have also got a query on the same page which is exactly the same apart from the collection name, and that works fine.
I'm getting the above error when running the following query. I've not seen it before, can't find any documentation about it, and I'm not doing anything unusual or anything I've not done before. Can anyone shed any light on it, please?
const getUserProjects = async () => {
return await useFireStore
.collection('projects')
.where('paid','==',true)
.where('ownerId','==', `${currentUser.uid}`)
.orderBy('createdAt', 'desc')
.onSnapshot(snapshot => {
let projects = [];
snapshot.forEach(doc => {
projects.push({...doc.data(), id: doc.id })
});
setUserProjects(projects);
});
};
It is a 'new' query in that I've just added it to the code, so I might expect the error in the console that gives a link for a new posite index to be created or whatever it's called, but I'm just getting this instead:
EDIT: I have tried manually creating an Index, but I still get the same error. I have also got a query on the same page which is exactly the same apart from the collection name, and that works fine.
Share Improve this question edited Jul 16, 2021 at 2:57 Martin Zeitler 77.2k20 gold badges166 silver badges238 bronze badges asked Jul 14, 2021 at 7:43 Ray PurchaseRay Purchase 7623 gold badges19 silver badges47 bronze badges 6- I'm seeing the exact same thing today – nycynik Commented Jul 15, 2021 at 6:15
- Hi, no, I'm still getting the error. Maximum number of posite indexes is 200, so it's not that either. Very frustrating – Ray Purchase Commented Jul 17, 2021 at 12:47
- Ok, I've tried setting up a pletely new project and every query that would normally result in the console outputting a message (and link) to create an Index is now just outputting the above error. – Ray Purchase Commented Jul 17, 2021 at 14:19
- 2 Getting the same error. Filed GitHub issue: github./firebase/firebase-tools/issues/3583 – Clive Townsend Commented Jul 17, 2021 at 23:10
- 3 UPDATE: Just received this from Google: "...We have received several reports similar to yours and the engineering team is already working to solve it. I added your case to the developers affected by this issue to continue pushing the solution..." – Ray Purchase Commented Jul 18, 2021 at 14:49
4 Answers
Reset to default 3This is an internal bug in the SDK.
Firebase team is working on it, follow the issue here.
That's a known issue with Client SDKs. However the Admin SDK still works as usual and returns throws an error containing the link to create index and can be used a workaround. Just use the Firebase Functions Emulator locally with the Admin SDK.
Use an existing Firebase project or create a new one for this:
firebase init functions
Copy the following function:
export const getIndexLink = functions.https.onRequest(async (request, response) => {
try {
const snap = await admin.firestore()...get()
// Paste your query here
response.send(snap.size, "matched documents");
} catch (error) {
console.log(error)
response.send(error.message)
// This error will contain the index creation link
}
});
Run the function emulator:
firebase emulators:start --only functions
Open a browser and paste your getIndexLink
function's URL and you should have the URL to create index there.
The problem is you must create an index for your "where" and "orderBy" conditions in the indexes column in your cloud firestore.
Official documentation:
- Manage indexes in Cloud Firestore
- Indexes and pricing
you have to create a new index manually from firestore console
- Go to the Cloud Firestore section of the Firebase console.
- Go to the Indexes tab and click Add index.
- Enter the name of the collection and set the fields you want to use to sort the index.
- Click Create.
more information: https://firebase.google./docs/firestore/query-data/indexing?authuser=0#create_a_missing_index_through_an_error_message
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744869712a4598185.html
评论列表(0条)