Ask Your Question
3

Can multiple "array-contains" queries be implemented in firestore through a workaround?

asked 2023-05-23 03:32:09 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-23 03:59:01 +0000

bukephalos gravatar image

Yes, multiple "array-contains" queries can be implemented in Firestore through a workaround. One approach is to denormalize the data by creating a separate collection for each value that needs to be searched. For example, if you have a collection of books and want to search for books that contain both "mystery" and "fiction" genres, you can create two additional collections: one for books that belong to the "mystery" genre and another for books that belong to the "fiction" genre. Then, you can perform "get" queries on both collections and intersect the results to find books that exist in both collections.

Another approach is to store the data in an alternative data store, such as Elasticsearch, which has better support for complex search queries. You can use Firestore triggers to keep the data in sync between Firestore and Elasticsearch.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-23 03:32:09 +0000

Seen: 9 times

Last updated: May 23 '23