Hi,

I have a custom entity type setup, and indexing works really well. I have an issue with deleting these entities:

- I delete multiple custom entities using hook_{entity}_delete()
- Search API properly sets 'changed' to 1 in search_api_item
- now I try a re-index of my search index: Couldn't index items. Check the logs for details.

Problem is (I think) that Search API doesn't "know" my entities were deleted. So it tries to index the change, but can't find my items. This means my items are stuck in the index, until I do a full "Clear index".

Is there a "way" to let Search API know about the deletion? Maybe a special action in my hook_entity_delete()? Maybe a changed=2 meaning "deleted"?

Comments

Anonymous’s picture

Extra information:

About 49% of all items have been indexed in their latest version (1887 / 3793).

I have 1887 custom entities, and they are indexed OK.
But all the others were deleted and are still in search_api_item with changed=1.

Edit-
Shouldn't the items be deleted instantly instead of setting changes=1`?

drunken monkey’s picture

Category: bug » support

- I delete multiple custom entities using hook_{entity}_delete()
- Search API properly sets 'changed' to 1 in search_api_item

This shouldn't happen – Search API should delete the items from the table (and the index), which would solve all problems you mention here. Cf. search_api_entity_delete() in search_api.module:646.

The only explanation I can imagine is that your module doesn't properly invoke hook_entity_delete() when deleting your custom entities, as it is required. Then, the Search API would of course not know about your items being deleted, seemingly just believing they were changed.

Anonymous’s picture

Status: Active » Closed (works as designed)

It does work, I messed up something else, sorry for bothering.