When marking a class with multiple @IndexEmbedded annotations, the depth variable is assigned at the class-level instead of the field-level.
public class MyTest() { @IndexEmbedded private Set<MyClass> myClass; @IndexEmbedded(depth=1) private Set<MySecondClass> myClass2; }
In looking at the source code for HibernateSearch, the AnnotationMetadataProvider's checkForIndexedEmbedded() method appears to share the parseContext across all fields within the class ( https://github.com/hibernate/hibernate-search/blob/d6f1ba9909857b967c17e32ea6289ab7909a9a51/engine/src/main/java/org/hibernate/search/engine/metadata/impl/AnnotationMetadataProvider.java#L1081) and set the maxLevel() there. Without stepping through the entire codebase, it would appear that this would cause the issue we're seeing whereby the depth is being set for all properties on the class (or possibly the entire parse tree) instead of just for that field.