hardy.ferentschik wrote:
You cannot use @IndexedEmbedded and @ContainedIn in your custom class bridge. These things are unrelated.
That said, I think you might misunderstand how many Lucene documents are getting created. You get one document for each instance which is marked with @Indexed.
In a object graph situation you only have to mark your top level entity (the one you want to retrieve as part of the search) as @Indexed. Marking a reference of this top level entity with @IndexedEmbedded (and the other side of the relationship with @ConstainedIn) does not mean that there will be a separate Lucene document created for this referenced object. in contrary. The referenced object gets added to the document of the main entity. It seems you replicated in your custom class bridge what Hibernate Search does by default.
--Hardy
Oh joy. I think the reason for creating the custom bridge was to group certain objects and place then in a custom field. Basically I wanted to group certain data and place them in a field like project.data which would use the embedded objects and group the data to gether. I presume this is possible to this with a custom field bridge and use @IndexEmbedded.
So effectively:
class AbstractProject
- User owner
@Indexed (top level entity and one i want to create a lucene document)
class Project extends AbstractProject
@IndexEmbedded
- Programme
@IndexEmbedded
- Set<SubProject> subProject
class SubProject
@ContaineIn
- Project
- Risk
<What should this entity be marked?>
- Programme
@Field (name="project.programme")
- reference
@Field (name="project.programme")
- description
@ContainedIn
Set<Project> projects
I have noticed that the field project.programme is being indexed as programme.project.programme which I don't want to do. Not sure how to remove this.
Not sure if the above made sense? Thanks for helping me out with this! Much appreciated.