【发布时间】:2014-07-24 21:46:29
【问题描述】:
我正在尝试使用休眠搜索(lucene)在我的应用程序中实现搜索功能。对字符串字段的简单搜索工作完美,但现在事情变得更加复杂...... 我希望你能给我一些提示或样本。
我有以下实体...
@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
}
========================================
现在我尝试搜索并找到例如:
"查找具有 child.enumtype = a 的子类的 ParentClasses 列表"
我可以使用 hql 或本机 sql 查询来做到这一点。但是如何使用 hibernate lucene 查询来做到这一点。
提前致谢
【问题讨论】:
-
只是为了澄清地图例如 @Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) @IndexedEmbedded(depth = 1) private Map
cmets ;我可以使用如下查询: luceneQuery = queryBuilder.keyword().wildcard().onField("cmets").matching(searchString).createQuery(); booleanJunction.should(luceneQuery);此查询按预期返回结果。我对上述用例有疑问
标签: hibernate collections enums lucene hibernate-search