algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

[Feature Request] Sync with collections OR collectionGroups #56

Closed deimantasa closed 3 years ago

deimantasa commented 3 years ago

Hello devs,

First of all - thank you for such an amazing and time saving tool. It really helps us to move much faster with Fire + Algolia.

One thing I found missing is support for collectionGroups. It would extremely help as currently, we've to have global collection in order for it to sync with Algolia. However there are many instances as it's better to nest it under some collection instead of keeping everything global.

As a workaround, we have subcollection and collection of the same thing. Collection is used for algolia only, and subcollection for other things. It would be great to rely on only subcollection in this case as it would take away this constant sync between main subcollection and collection which is only used in Algolia.

Looking forward!

Cheers

dvarnes commented 3 years ago

Do you know that the existing function already works for sub-collections?

Just specify the full sub-collection path: rootCollection/{someDocId}/subCollection/{someDocId}

deimantasa commented 3 years ago

This will index only specific subCollection. My goal is to index all subCollections with the same name (collectionGroup).

Example: collection - users subCollection - cars

I want to listen for changes that happen in any subcollection of cars (thus collectionGroup) instead of single one as per your sample.

smomin commented 3 years ago

You can do this by setting the sub-collection path to : users/{parentId}/cars. You will need to have two Algolia extensions installed. One to listen on the users collection and the other to listen for the users/{parentId}/cars subcollection.

reference #36

deimantasa commented 3 years ago

Wow - that's terrific. Just ran a test and indeed - it works!

Would be nice to add some description about it, as it was not clear in the beginning that sub-collections are taken into account as well.

Thank you for prompt help!

vivekraj commented 1 year ago

@smomin

You will need to have two Algolia extensions installed. One to listen on the users collection and the other to listen for the users/{parentId}/cars subcollection.

Both points to the same algolia index or should be pointing to separate indexes?