Index only parent class

Hello everyone,

i have a case with multiple inherited class but i would like to index only the field contained inside the parent class

class A
class B extends A
class C extends A
class D extends A

and i would like only the index of A with the common fields

How i can do that ?

thank :slight_smile:

If you mean you don’t want to index instances of A, but not instances of B, C or D, then just use @Indexed(enabled = false) on B, C and D. See here.

If you want to index B, C and D, but want them to be indexed in the same index as A, then that’s not possible in Hibernate Search 6. Your only option is to have one index per type. Note that this generally does not matter, because indexes for A, B, C and D can perfectly well have the same schema, and you can definitely search across all these types (that’s what will happen when you use .search(A.class): it will search across A, B, C, and D).