Answer the question
In order to leave comments, you need to log in
What is the correct way to use whereGreaterThan(), orderBy() and startAt() in a query (Firebase)?
Please tell me how to make a request. The collection contains note objects with title, description, priority fields. I need to get only those with:
collectionReference
.whereGreaterThan(KEY_PRIORITY, 1)
.orderBy(KEY_TITLE)
.orderBy(KEY_PRIORITY)
.startAt("A")
java.lang.IllegalArgumentException: Invalid query. You have an inequality where filter (whereLessThan(), whereGreaterThan(), etc.) on field 'priority' and so you must also have 'priority' as your first orderBy() field, but your first orderBy() is currently on field 'title' instead.
Answer the question
In order to leave comments, you need to log in
Errors:
1 - sorting must always precede other operations in the record, i.e.
ref.OrderBy(KEY_PRIORITY).whereGreaterThan(key_priority, 1)
collectionReference.whereGreaterThan(KEY_PRIORITY, 1)
) and already on the client you filter out everything that does not start with "A", or enter an additional field, for example, firstLetter and put the first letter there for each entry. In this case, the request would look something like this:Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question