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?

Activity

Show:
Fixed

Details

Assignee

Reporter

Components

Sprint

Fix versions

Affects versions

Priority

Created September 7, 2020 at 3:38 PM
Updated October 8, 2020 at 12:30 PM
Resolved September 23, 2020 at 1:56 PM