Skip to content Skip to sidebar Skip to footer

Firestore Composite Index Sort Not Modifying Order

Issue The order of the data returned is not changing using a Firestore multiple attribute composite index sort. This is compared to the original sort performed on one attribute. Cu

Solution 1:

You call .orderBy(TIMESTAMP, DESCENDING).orderBy(QUALITY_SCORE, DESCENDING). This means that the documents are first ordered by descending timestamp, and when those are the same, they are ordered by descending quality score.

Since all documents in the result set have a unique timestamp, that is the only visible result. Only when multiple documents have the same value for the first sort field, does the second sort field become relevant.

Post a Comment for "Firestore Composite Index Sort Not Modifying Order"