As a follow up of discussions on https://issues.jboss.org/browse/ISPN-5103 : performance analysis in Infinispan highlighted that there is a significant performance benefit in enabling single-term delete rather than a query-based delete.
We already were aware of this and Hibernate Search will apply the better performing single-term delete operations (and update operations) when safe, but the definition of "when safe" is very conservative.
Currently the optimisation is only enabled when both of these are true:
- org.hibernate.search.indexes.impl.PropertiesParseHelper.isIndexMetadataComplete(Properties, WorkerBuildContext) returns true (the default but can be configured otherwise)
- there is a single type in the index (the IndexManager owns only one entity type)
In reality even if the IndexManager were to contain multiple types, this would be safe as long as we can guarantee that no type has an ambiguity on the keyword used for the ID encoding.
Some cases in which this is actually possible to figure out:
- there are multiple types but they are mapped in an inheritance mode on ORM, which would force them to have a unique ID across different instance types
- all types sharing the index have field bridges on the primary ID which would necessarily result in incompatible encodings
The second case might be complex to hit in practice (or just complex to evaluate), but I think the first case is probably the most common reason for one to possibly have multiple types sharing the same index, so that would be a great enhancement.