Making a nested Firestore collection full-text-searchable with Algolia

19 Views Asked by At

I have a "users" collection, each user has a sub-collection "entries". This sub-collection needs to be full-text-searchable, filterable and searchable. That should be completely separate, so one user can't read or write any entries of another user.

I have successfully used Algolia with the "Search Firestore with Algolia" extension before for such a use-case but only a top-level collection, not a sub-collection. I'm unsure as to how to achieve this.

In my opinion, there are two ways of achieving this:

  1. Create separate Algolia Indexes for each user. This means I need a way to automate the creation of an index in Algolia.

  2. Creating one top-level collection for all entries in Firestore and storing the user's id in it. This would mean I could use the Algolia Firestore Extension for syncing with an "entries" Algolia index. However, when searching, I would also always filter for the current user's query.

For my used Firestore data structure, I would prefer to use the first method, however, I don't know how to automate creating Algolia indexes.

What is the best method to achieve this use case? Are there any resources for learning how to achieve this behavior?

0

There are 0 best solutions below