I have a unidirectional many-to-one association between Item and TechnicalCategory classes. An Item contains a single instance of TechnicalCategory, but the same TechnicalCategory can be applied to multiple items. It is possible someone may wish to search on an Item by TechnicalCategory. However, my tests are returning no hits when there absolutely should be.
Here is the association found in my Item class
Code:
@ManyToOne
@JoinColumn(name = "TECHNICAL_CATEGORY_ID", nullable = false)
@Field(index = Index.TOKENIZED, store = Store.NO)
@IndexedEmbedded
@FieldBridge(impl = TechnicalCategoryStringBridge.class)
public TechnicalCategory getTechnicalCategory() {
return technicalCategory;
}
In case it matters, TechnicalCategoryStringBridge simply provides a way to represent TechnicalCategory as a String by calling its toString method, which returns the name of the category.
I have added all the trimmings to my TechnicalCategory class like @Indexed, @DocumentId, and @Field on the name, which is what will be searched on.
Here are my questions:
1) Is there anything obviously wrong with my setup?
2) Where do I add @ContainedIn? What other annotations must I add if any?
3) Do I need to make this association bi-directional? In other words, must TechnicalCategory have a reference to Item as well? Such a thing is unnecessary for the purposes of my application, but I am willing to do it if it is necessary for Hibernate Search.
Any insight is appreciated.
Thanks.