【发布时间】:2017-08-10 13:07:09
【问题描述】:
我正在使用 Hibernate 和 Hibernate 搜索来索引弹性搜索中的类 + 数据(从 java 到 elasticsearch)。我已经设置并提供了所有属性。 例如:
@Entity
@indexed(name="a")
public class a{
@Id
@Generated value
private integer i;
@Field(index=index.yes, analyze=analyze.no, store=store.yes, norms = norms.no)
private String b;
//Getter and Setter
}
在我的主要方法中,我将值传递给这个类并保持不变。当我这样做时,我收到错误消息,上面写着
[string] 类型在 5.0 中被移除。您现在应该使用 [text] 或 [keyword] 并且由于 boost 参数而禁用了自动升级。
给你更多的细节
它以这种模式发送 Json 输入
PUT a/a_mapping
{
"properties":{
"i":{
"type": "String"
"boost":1.0,
"index": not_analyzed
"store":yes
},
"b":{
"type": "String"
"boost":1.0,
"index": not_analyzed
"store":yes
我在玩了之后了解到,字符串数据类型在 ES 5.0 中已被弃用,因此进入的 'String' 数据必须转换为 'Keyword' 或 'Text',Hibernate Search orm 会执行此操作,前提是没有 boost 参数(我尝试手动输入此参数,无论是否使用 boost 参数,它都适用于后者)。
所以我得出的结论是,我必须选择这两个选项之一才能通过休眠将数据发送到 ES。
1) 要么构建了一个字段桥,它将数据类型从对象转换为关键字
2) 禁用索引时间提升参数,以便在索引时不输入提升。
到目前为止,我还没有找到解决这些问题的方法,任何提示或帮助将不胜感激。
TIA
【问题讨论】:
标签: hibernate elasticsearch lucene hibernate-mapping hibernate-search