Re: [Firebase] Trouble using 'orderBy' with Firestore database

526 views
Skip to first unread message

Samuel Stern

unread,
Oct 30, 2017, 9:29:17 AM10/30/17
to fireba...@googlegroups.com
Is it possible that some of your documents are missing fields?  All "orderBy" queries are also an implicit filter, if the document does not have the field on which you are ordering it will not be returned.

So your second query will only return documents that have both USER_KEYWORDS.activeKey and USER_KEYWORDS.dateKey.

- Sam

On Fri, Oct 27, 2017 at 2:59 PM tutanck <tut...@gmail.com> wrote:
HI,
when i query the Firestore database without using 'orderBy'  i get the right results.
But when i use 'orderby' (with a composite index), the results are completely random.

index :



code :

Query
mLoadQuery
= db.collection(coll).document(id).collection(subcoll).whereEqualTo(USER_KEYWORDS.deletedKey, false);
mLoadQuery.get() returns the right results (all documents not 'deleted').

but

mLoadQuery.orderBy(USER_KEYWORDS.activeKey, Query.Direction.DESCENDING).orderBy(USER_KEYWORDS.dateKey).get()
returns only the first document.

I didn't limit the results.

I have the same issue with another collection and the results do not make sense.



--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/1f08d234-6a03-43b4-9334-92fbfcda7098%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages