Closed rschellhorn closed 13 years ago
Yea that's a feature I have been planning to add, it's been hard to find time but I will make it happen.
Any help is appreciated of course.
Working on it!
You are a star dude! Let me know when you want the next release
I've just created a pull request which adds @ElasticSearchEmbedded.
By default it will embed all properties not annotated with @ElasticSearchIgnore, so as in your example the index for Education would get additional fields "institution.name" and "institution.type". You can also override which fields should be indexed by using the fields attribute on the annotation.
E.g.: @ElasticSearchEmbedded( fields = { "name" } ) will only embed "institution.name" in the index.
Note: for now the code only handles simple embedded properties, which are owned by the entity being indexed. I have looked into handling for embedded fields from an entity which is not owned, byusing something akin to hibernate-search's @ContainedIn, which helps to provide a clue regarding when to update the embedded fields. However, this is quite a hassle to integrate into the current code (been trying to do that for a day).
Suppose the following:
class Institution { public String name; public String type; }
@ElasticSearchable class Education { ... @Embedded Institution institution; }
It would be really nice if the institution name and type are added to the index, preferably by the name institution.name and institution.type. Unfortunately currently one field institution is being created, containing the toString of the embeddable type.