Using @IndexedEmbedded for object associations
Using @IndexedEmbedded for object associations allows you to express queries (using Lucene's query syntax) such as: Return places where name contains JBoss and where address city is Atlanta. In Lucene query this would be +name:jboss +address.city:atlanta Return places where name contains JBoss and where owner's name contain Joe. In Lucene query this would be +name:jboss +address.orderBy_name:joe In a way it mimics the relational join operation in a more efficient way (at the cost of data duplication). Remember that, out of the box, Lucene indexes have no notion of association, the join operation is simply non-existent. It might help to keep the relational model normalized while benefiting from the full text index speed and feature richness. Note An associated object can itself (but does not have to) be @Indexed When @IndexedEmbedded points to an entity, the association has to be directional and the other side has to be annotated @ContainedIn (as seen in the previous example). If not, Hibernate Search has no way to update the root index when the associated entity is updated (in our example, a Place index document has to be updated when the associated Address instance is updated). Sometimes, the object type annotated by @IndexedEmbedded is not the object type targeted by Hibernate and Hibernate Search. This is especially the case when interfaces are used in lieu of their implementation. For this reason you can override the object type targeted by Hibernate Search using the targetElement parameter. Example 4.6. Using the targetElement property of @IndexedEmbedded @Entity @Indexed public class Address { @Id @GeneratedValue @DocumentId private Long id; @Field(index= Index.TOKENIZED) private String street; @IndexedEmbedded(depth = 1, prefix = "ownedBy_", targetElement = Owner.class) @Target(Owner.class) private Person ownedBy; ... } @Embeddable public class Owner implements Person { ... }