在 Hibernate Search 5 中,我有几个填充相同字段的自定义桥。这很方便,因此我可以只对一个字段执行查询。现在,如果我尝试这样做,我会收到此错误:
HSEARCH600034: Duplicate index field definition: 'attributes'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
在实现 PropertyBinder 时,我还没有找到从 PropertyBinding 上下文获取现有字段的方法,只有记录在案的添加新字段的方法:
IndexFieldReference<String> attributesField = schemaElement
.field("attributes", f -> f.asString())
.toReference();
我是否遗漏了什么或不再可能,我需要添加新字段?
如何在 Hibernate Search 6 的几个桥中重用一个字段?
目前,你不能。
这种限制是 Hibernate Search 6 在启动时执行的(许多)健全性检查的副作用,它可以防止常见错误并间接允许搜索 DSL 中的更直观的行为。
您的选择几乎是这样的:
TypeBridge
或PropertyBridge
应用于返回您感兴趣的所有值的聚合列表的非持久化 getter )。第二种解决方案也是推荐的索引方式,因为它会产生更准确的相关性分数。
编辑:如果您选择解决方案 2,您可能会对这个(尚未实现)功能感兴趣:https ://hibernate.atlassian.net/browse/HSEARCH-3926
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句