'How to use whereIn filter multiple times in a query

I am using this code to retrive data from firestore

querysnap = FirebaseFirestore.instance
                              .collection("datas")
                              .where("cat", whereIn: Cateogryarray )
                              .where("City", whereIn:Cityarray)
                              .snapshots();

Then I get this error.

You cannot use 'whereIn' filters more than once.

How can I execute this query.



Solution 1:[1]

As the Firestore documentation on query limitations says:

You can use at most one in, not-in, or array-contains-any clause per query. You can't combine these operators in the same query.

Since you're trying to use two in clauses in your query, Firestore gives an error.

The most common workaround is to run with one clause against the database (typically the one you expect to exclude most documents from the result), and perform the rest of the filtering in your application code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Frank van Puffelen