0

I am trying to find a way to do an OR query in a collection of "object" documents.

Each object document has a "type" field which is an array.

object1:
 - name:
 - description:
 - types:["type-a","type-b","type-d"]
 - createdOn


object2:
 - name:
 - description:
 - types:["type-a","type-d"]
 - createdOn


object3:
 - name:
 - description:
 - types:["type-d","type-h"]
 - createdOn

object4:
 - name:
 - description:
 - types:["type-b"]
 - createdOn

How can I do a query such that I get the object documents that either belongs to type-a or type-b? For example, for the above case of a collection, the result should be object1,object2,object4 ordered by createdOn field if possible.

Note that there are millions of "object" documents. So the operations should be as efficient as possible performance-wise, cost-wise, data transfer rate wise (battery life for a mobile app).

Very much appreciated!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
honor
  • 7,378
  • 10
  • 48
  • 76
  • Cloud Firestore currently does not support this type of query (internally called an `IN` query), since we haven't yet figured out how to do so while maintaining our performance guarantees. For the moment you'll have to do a separate query for each value, and then merge the values client-side. – Frank van Puffelen May 04 '19 at 14:07

1 Answers1

1

firebaser here

Cloud Firestore currently does not support this type of query (often referred an IN query), since we haven't yet figured out how to do so while maintaining our performance guarantees.

For the moment you'll have to do a separate query for each value, and then merge the values client-side.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks, Frank. Do you know if there are any plans to make this possible in the future? I mean is the team working on it? Is there any feature requests from the community? – honor May 05 '19 at 05:35
  • Hi Frank. What would you say about this problem: https://stackoverflow.com/questions/56028262/react-native-firestore-paging-with-multiple-parallel-promises-inside-promise-all I would like to hear your opinion on this... That problem is born out of this one... – honor May 07 '19 at 20:55