I'm using Hibernate Search and looking to index an object that has polymorphic relationships that use @Any and/or @ManyToAny.
@Indexed
public class Foo {
@Any(metaDef="fooOwnerType", metaColumn=@Column(name="ownerType"))
@JoinColumn(name="ownerId")
@IndexedEmbedded // this DOES NOT WORK
private OwnerType owner;
@OneToOne
@IndexedEmbedded // this WORKS
private User user;
@OneToOne
@IndexedEmbedded // this WORKS
private Company company;
@Field
private String description;
}
@Indexed
public class User implements OwnerType {
@Field
private String name;
@Field
private String address;
}
public class Company implements OwnerType {
@Field
private String name;
}
public interface OwnerType {
}
I can search and find Foo objects using text in the description field without issue. What I'd also like to do is find Foo objects when User.name or User.address is matched... but Hibernate Search doesn't seem to index these fields for me due to the polymorphic relationship OwnerType owner.
It would work fine if I use @IndexedEmbedded on a concrete object (User or Company) directly as expected.