Add Firestore indexes to local emulator
See original GitHub issue[REQUIRED] Environment info
firebase-tools: 7.15.0
Platform: Ubuntu 18.04.4
[REQUIRED] Test case
I’m trying to test our Firestore indexes, but they seem to always be working (regardless of the indexing settings included in firestore.indexes.json
). Below is the test case in question:
const FILTERS = {
'grade': ['==', TUTOR.grade],
'gender': ['==', TUTOR.gender],
'location': ['==', TUTOR.location],
'type': ['==', TUTOR.type],
'payments.type': ['==', TUTOR.payments.type],
'config.showProfile': ['==', true],
};
const SORTERS = [
'avgRating',
'numRatings',
];
describe('Tutorbook\'s Database Indexing', () => {
const db = authedApp({
uid: PUPIL.uid,
email: PUPIL.email,
access: PUPIL.access,
});
const filterCombos = combinations(Object.keys(FILTERS));
return Promise.all(filterCombos.map(filters => it('lets users filter ' +
'profiles by ' + filters.join(', '), () => {
var query = db.collection('users')
.where('access', 'array-contains-any', PUPIL.access);
filters.map(filter => query =
query.where(filter, FILTERS[filter][0], FILTERS[filter][1]));
return Promise.all(SORTERS.map(sorter =>
firebase.assertSucceeds(query.orderBy(sorter).get())));
})));
});
[REQUIRED] Steps to reproduce
Just try testing any type of composite or collection group query that would (normally) require an index. It will work on the emulator suite regardless of the existence of the required index (but it won’t work in production without the index).
[REQUIRED] Expected behavior
These tests should fail unless there are Firestore indexes (specified in firestore.indexes.json
) that support the composite indexes tested.
[REQUIRED] Actual behavior
All the tests succeed (even though they shouldn’t).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:88
- Comments:50 (17 by maintainers)
Top Results From Across the Web
Manage indexes in Cloud Firestore - Firebase - Google
Go to the Cloud Firestore section of the Firebase console. · Go to the Indexes tab and click Add Index. · Enter the...
Read more >Create firestore index from firebase admin SDK with emulator
The recommended way to create indexes for firestore is ...
Read more >Emulate Firestore locally
Run the following command to start the emulator: gcloud emulators firestore start. The emulator prints the host and port number where it is...
Read more >The Full Guide on how to use the Firebase Emulator ...
Once you added all the data to Firestore if you stop the emulator and start it again, it will start empty, so you'd...
Read more >Firestore: Can't create missing index by clicking on link (url ...
If you are using firebase functions, you can serve the local emulator and hit your firestore query... it will then return you an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Any update on this? It’s unbelievable that in 2022 we can still ship broken code to production because of such issue…
@IchordeDionysos fully agree! This is really hard to test and we want to improve it.