sanity-io / sanity-algolia

Utilities for indexing Sanity documents in Algolia
MIT License
67 stars 16 forks source link

Delete based on field value #63

Open bzmillerboy opened 6 months ago

bzmillerboy commented 6 months ago

Is it possible to delete an Algolia record based on a field value versus the document delete projection in the webhook?

Use Case: We have inventory items that we retain even when the inventory item is "sold". The stockStatus value designates if it's inStock or sold. When an item is inStock then we sync it to Algolia, however, when it later changes to sold (but not deleted), it doesn't get removed from the Algolia index. We don't want sold inventory items in our index as they are no longer relevant (they will never come back to inStock status.

Possible Work Around: I realize I could index all items and include a field for stockStatus, however it seems like index bloat and would require further diligence to assure sold items are filtered out.