There are multiple invocations of delete operations for all registered indexes, even if it is the same one.
Solution
There are a few possible solutions to fix this bug:
Fetch the data for ids in deleted collection and filter objects by type as you did in saveObjects operation
To avoid additional calls to the Sanity, it might be a good idea to put all indexers into a unique collection like Set and delete records only from unique indexers.
Problem
There are multiple delete requests to the same Algolia search index if there are multiple types defined.
Steps to reproduce
Code issue
There are multiple invocations of delete operations for all registered indexes, even if it is the same one.
Solution
There are a few possible solutions to fix this bug:
deleted
collection and filter objects by type as you did insaveObjects
operation