使用以下版本进行休眠搜索:
在放置实例的实例时,我遇到了includePaths
注释@indexedEmbedded
属性的问题。例如:(假设所有字段都有适当的getter / setter)
根类:
@Indexed
public class RootClass {
@IndexedEmbedded
private Set<Instance> setOfInstances;
}
实例类:
public class Instance {
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String name;
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String vesion;
@IndexedEmbedded(includePaths={"type", "location", "users.name", "users.country"})
private InstanceDetail deltail;
}
InstanceDetail类:
public class InstanceDetail{
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private int type;
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String location;
@IndexedEmbedded
private Set<User> users;
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String ref1;
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String ref2
@IndexedEmbedded
private Set<Area> usersArea;
}
用户类:
public class User{
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String name;
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String address;
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String mobile;
@Field(index = Index.YES, analyze = Analyze.YES, norms = Norms.NO, store = Store.NO)
private String country;
}
因此,当我在includePaths
的{{1}}上定义 IndexedEmbedded
注释的 InstanceDetail
属性时, > 字段 Instance
(其他人来得像名字/ vesion)正在为RootClass对象编制索引。 (按日志确认)。没有任何例外。
所以这是根据HibernateSearch的设计或者与我的实现有关的东西。
答案 0 :(得分:0)
它应该有效,但您可能遇到与https://hibernate.atlassian.net/browse/HSEARCH-1112
相关的错误答案 1 :(得分:0)
您必须在depth
上的@IndexedEmedded
注释中指定Instance.deltail
才能获得InstanceDetail
的属性。根据Javadocs:
当深度达到深度= 1表示停止索引嵌入元素 关联元素是索引的,但不是其嵌入元素。
默认值取决于includePaths属性的值: 如果没有定义路径,则默认为Integer.MAX_VALUE;如果有的话 定义了includePaths,如果没有,则默认深度被解释为0 指定为与其默认值不同的值。
将depth
设置为1
会嵌入InstanceDetail
的属性,而将其设置为2
则会嵌入InstanceDetail
及其关联的属性User
秒。