HQL deletion does not trigger Elasticsearch deletion


#1

session.delete(entity) causes entity to be deleted from both the DB and Elasticsearch while executing an equivalent HQL deletion query causes the entity to be deleted from the DB but not from Elasticsearch. Is this expected?


#2

It is expected. Delete queries are executed without the client (Hibernate Search, and Hibernate ORM for that matter) knowing what is deleted exactly.

Similarly, if you use a second-level cache, it won’t be updated to reflect the changes performed by your HQL query. Though I suppose it’s less critical with delete queries than it is with update queries.