algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

Algolia index not updating deleted fields. #60

Closed kshitijsubedi closed 3 years ago

kshitijsubedi commented 3 years ago

Here's what happening :

  1. I remove a field on firestore collection. [field 'type' in my case]
  2. The respective field is not deleted on algolia index. [I can still see 'type' on algolia index, I refreshed browser many times and even checked after few hours]

before deletion I tested by changing the field data and the changes are reflected on index. Just that the firestore field deletion part does not delete on algolia index. Am I missing something or is it an issue??

smomin commented 3 years ago

No, you are not missing anything. The extension uses partialUpdate for creating and updating records. The method is used because of its ability to version records so it can be used to prevent race conditions. How often do you remove the fields?

asentris commented 3 years ago

@smomin Would you recommend deleting the document and re-inserting it into the Firestore database in cases where a field is deleted? I think it would help if this caveat could be noted in the documentation (please correct me if I missed it). This is a necessary feature for my app, so if it's possible, it would be a great benefit to include! Thank you for your work!

kshitijsubedi commented 3 years ago

@smomin not often, but I have some fields on the index that are deleted on the firestore and don't want those on algolia. There are close to one hundred objects that have deleted fields. What can I do to remove those fields from algolia?

smomin commented 3 years ago

I am thinking through an approach that will clean up null attributes. Will update when I have a solution.

Haroenv commented 3 years ago

We should change

https://github.com/algolia/firestore-algolia-search/blob/dc264bec3ba2b2f9b8b7263a96686707d42928de/functions/src/index.ts#L69

and

https://github.com/algolia/firestore-algolia-search/blob/dc264bec3ba2b2f9b8b7263a96686707d42928de/functions/src/index.ts#L52

to saveObject, as that will take deleted fields in account, replacing the whole object.

smomin commented 3 years ago

@kshitijsubedi I think i have a solution in mind, but I will need time to write the code. I will attach the PR to this issue once I have it ready.

samsamlh commented 3 years ago

I also need this behavior to be implemented 🙏

asentris commented 3 years ago

@smomin I'm curious why this was closed? This issue still remains.

smomin commented 3 years ago

This was automatically closed after the PR was merged to the main branch.