algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

Subcollections support #36

Closed zphoenixz closed 3 years ago

zphoenixz commented 3 years ago

It's not possible to have a subcollection tied to the function, it has to be on the root or it won't work.

smomin commented 3 years ago

I am not sure I understand your use case. If you can provide more details, I can try to look into it. thanks

zphoenixz commented 3 years ago

Sorry, what I meant is that if it's possible to use listeners to collections with interpolated document keys something like "parent_collection/$document_id/target_collection"

smomin commented 3 years ago

It is supported. Example syntax is parent_collection/{parentId}/target_collection. One note, there is not depublication process on subcollections. So if there is a record with the same data in multiple sub collection but with different ids, you will have multiple corresponding records in Algolia.

smomin commented 3 years ago

Also, if you plan to use a new index for the subcollection, make sure the API key you are using has the proper permission.

smomin commented 3 years ago

Reopen the issue if you have further questions.

BenWueb commented 1 year ago

Could you provide the proper syntax for adding a subcollection. I have tried the below with no success.

Recipes/{parentId}/recipes Recipes/{documentId}/recipes

smomin commented 1 year ago

Can you provide more detail on this issue? Are the parent and child collection both called recipes?

guplem commented 1 year ago

I have the following structure:

It should work by setting up the path like ParentCollection/{parentId}/SubCollection.

This appears in the readme

I was confused because after the initial sync I saw nothing in the Agolia records. Creating/Updating documents did make them appear as records in Agolia, so I started looking and found this issue describing this same behaviour.