I am trying to search Firestore documents using StartAt() and EndAt() but I keep getting the error
Too many arguments provided to startAt(). The number of arguments must be less than or equal to the number of orderBy() clauses.
I also have OrderBy included as indicated in this stackoverflow post -> Firebase Error - Too many arguments provided to Query.startAt()
The firestore query is being called as part of AutoCompleteTextView, not sure whats the issue here....
val mIndFilter = FirebaseFirestore.getInstance()
mIndFilter.collection("Industries").orderBy("industry").startAt(queryString).endAt(queryString + '\uf8ff').limit(5).get()
.addOnCompleteListener {
if(it.isSuccessful){
allIndList = it.result.toObjects(Industries::class.java)
}
}
.addOnFailureListener { exception ->
Log.e("Ind Search Filter fail", "Error adding document $exception")
}
i literally ran into the same problem yesterday. here is how i solved it. hopefully it works for you too. use where clauses instead of startAt and endAt.
.collection("Industries")
.orderBy("Industries", "asc")
.where("Industries", ">=", queryString)
.where("Industries", "<=", queryString + "\uf8ff")
.limit(5)
.get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With