1

I had to do something like this while querying in Flutter Firebase;

Query nameRef = _firestore
        .collectionGroup("Posts")
        .where("name", isEqualTo: "word that I want search") or _firestore
        .collectionGroup("Posts")
        .where("writer", isEqualTo: "word that I want search");

But I couldn't find a right solution for this usage.

In other words, if the word I want to search is equal to writer or post name, I want to display the posts that are equal.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Rkdio
  • 153
  • 2
  • 13
  • The Firebase Realtime Database and Cloud Firestore are two separate databases. Please only mark your question with the relevant tag, not with both. – Frank van Puffelen Nov 22 '21 at 15:34
  • There is no way to perform an OR query across multiple fields in Firestore. You will need to perform two separate queries, and merge the results in your application code. See the questions I linked, and also this one in case you wonder why Firestore doesn't support what you may consider a basic query: https://stackoverflow.com/questions/54969057/firestore-why-do-all-where-filters-have-to-be-on-the-same-field – Frank van Puffelen Nov 22 '21 at 15:35

0 Answers0