When marking a class with multiple @IndexEmbedded annotations, the depth variable is assigned at the class-level instead of the field-level.
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.
Hardy, I was able to temporarily fix our use-case by setting our depth=2 instead of 1. At this point we're on a development branch with 4.4.0/4.4.1 and expect to be for a while. Even said, I think we should be okay even putting this into production if a fix isn't there.
I'm glad my reading of the code parallels yours. Sorry for not including a test case.
I would recommend also taken this problem into consideration when rewriting the algorithm:
This is very likely fixed in Search 6, probably also in Search 5. We need a test case in Search 5 and 6 just to be sure.
For Hibernate Search 6: Added the test for it. It already works.
Same for Hibernate Search 5. Added the test for it. It already works. So this issue can have `5.11.2.Final` as fixed version too.