Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many arguments provided to startAt

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")
    }
like image 273
madhall Avatar asked Nov 05 '22 23:11

madhall


1 Answers

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();
like image 192
Strid3r21 Avatar answered Nov 30 '22 12:11

Strid3r21