Basic code is here, but we don't have tests in ORM, and I discovered problems when I added a test.
In particular, when the @DocumentId is the @Id, we should use the provided ID in priority and only if it's missing, unproxy the entity and get the ID;
when the @DocumentId is NOT the @Id, always ignore the provided ID. See org.hibernate.search.engine.impl.WorkPlan.PerClassWork.extractProperId(Work) in Search 5.
See this branch: https://github.com/yrodiere/hibernate-search-6-poc/tree/HSEARCH-3203