I am having trouble using firestore index merging in order to reduce the number of required indices.
Consider this example situation:
Firestore Collection: test/somedoc
{
a: '1',
b: '1',
c: '1',
d: '1'
}
This will cause Firestore to create 4 automatic single field indices on test for fields a to d.
Querying this table with a few equality conditions and one unrelated sort:
await db.collection('test')
.where('a', '==', '1')
.where('b', '==', '1')
.where('c', '==', '1')
.orderBy('d')
.get();
This causes Firebase to fail with a prompt for a composite index creation with all fields included. This is expected.
Now according to the docs (https://firebase.google.com/docs/firestore/query-data/index-overview#taking_advantage_of_index_merging), if you already have a composite on e.g. fields c and d, firestore will use index merging instead of requiring a composite index on all fields.
However if you create an index on collection test e.g. with c asc, d asc, the query will still fail with prompting to create the full composite index.
UnhandledPromiseRejectionWarning: FirebaseError: The query requires an index.
What am I doing wrong here?