Hi,
I'm looking into Hibernate Search relational mapping, and @IndexEmbedded.
I saw the "depth" property, but I need better control over fields of embedded objects:
Say I'm indexing Movies and Actors.
- Actors should be searched as stand-alone, and also embedded inside Movie.
- When explicitly searching Actors, I want to search by actor name & biography.
- When searching Movies, I want to search by movie title & actor NAME (but not actor biography).
Code:
// Actors should be searched by name + biography:
@Indexed public class Actor{
@Field private String name;
@Field private String biography;
}
// Movies should be searched by title + actor.name (but NOT actor.biography):
@Indexed public class Movie{
@Field private String title;
@IndexEmbedded private List<Actor> actors;
}
Thus Tom Cruise gets the following Lucene Document:
- name="Tom Cruise"
- biography="Born in united states, divorced from Nicole..."
While the movie "Mission impossible" gets the following Lucene Document.
- title="Mission Impossible"
- actor.name="Tom Cruise"
- ... but I don't want to generate "actor.biography", it's huge and useless.
Can this be achieved?
Thanks :)