Mass indexing a (non-abstract) parent class in a type hierarchy with a subclass annotated with @Indexed(enabled = false) still indexes that subclass

Description

Relevant Search 5 test: org.hibernate.search.test.batchindexing.IndexingGeneratedCorpusTest

It seems the method org.hibernate.search.mapper.orm.massindexing.impl.IdentifierConsumerDocumentProducer#index passes the root type to indexer.add. This will only work properly if the root type has no subtype; otherwise, this will result in instances of a subtype being treated as the root type: if the root type is not indexed, it will fail; if both the root type and the subtype are indexed, but the subtype defines additional fields, those will be ignored.
This should be fixed by detecting the type with org.hibernate.search.mapper.pojo.model.spi.PojoRuntimeIntrospector#detectEntityType, at least when the root entity type has entity subtypes. If the type is not indexed, this should be detected and the entity should be ignored.

Ideally, the query generating the IDs to reindex should also exclude IDs of instances of subtypes that are not indexed, but I'm not sure that's possible?

Environment

None

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Affects versions

Priority

Major
Configure