Hibernate lucene搜索集合和枚举
我正在尝试使用hibernate searchlucene在我的应用程序中实现搜索功能。字符串字段上的简单搜索工作得很完美,但现在事情变得更复杂了。。。。 我希望你能给我一些提示或样品 我有以下实体Hibernate lucene搜索集合和枚举,hibernate,collections,enums,lucene,hibernate-search,Hibernate,Collections,Enums,Lucene,Hibernate Search,我正在尝试使用hibernate searchlucene在我的应用程序中实现搜索功能。字符串字段上的简单搜索工作得很完美,但现在事情变得更复杂了。。。。 我希望你能给我一些提示或样品 我有以下实体 @Entity @Indexed public class ChildClass { @Enumerated @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) private EnumTy
@Entity
@Indexed
public class ChildClass {
@Enumerated
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
private EnumType enumType;
....
//getter setter
}
========================================
@Entity
@Indexed
public class ParentClass {
@IndexEmbeded
List<ChildClass> childs;
//getter setter...
}
public enum EnumType {
a,b,c
}
=======================================
@Entity
@Indexed
public class ParentClass {
@IndexEmbeded
List<ChildClass> childs;
//getter setter...
}
public enum EnumType {
a,b,c
}
现在我尝试搜索并查找,例如:
查找具有child的父类列表,其中child.enumtype=a
我可以通过hql或本机sql查询来实现这一点。但是如何使用hibernate lucene查询来实现它
提前感谢您对@IndexedEmbedded的使用不适用于这种情况-在我看来,您的子类是一个实体,与子实体中的通常情况一样,它们引用它们的父类,因此父类对它们的子类具有双向映射
如前所述,地址是用例示例
确保Place Lucene文档的地址更新
更改时,您需要标记双向的另一侧
与@ContainedIn的关系
@ContainedIn仅对指向实体的关联有用
与嵌入的对象集合相反
也许您可以在您的子列表上尝试@ContainedIn注释
总之:
您可以在父属性上使用@IndexedEmbedded从子级添加到父级
您可以从父集合到集合双向使用@ContainedIn
仅用于澄清地图,例如@Fieldindex=Index.YES,analyze=analyze.YES,store=store.NO@indexedembeddedpeth=1个私有地图注释;我可以使用这样的查询:luceneQuery=queryBuilder.keyword.wildcard.onfildcomments.matching searchString.createQuery;booleanJunction.shouldluceneQuery;此qurey按预期返回结果。我对上面描述的用例有问题,谢谢您的回复,到目前为止我理解,但是对于上面的szenario,luceneQurery应该是什么样子,正如您所看到的,我已经尝试了@IndexEmbedded