在我的映射中使用此字段
"answer": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
我尝试执行此聚合
"aggs": {
"answer": {
"terms": {
"field": "answer"
}
},
但我收到此错误
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [answer] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
我是否必须更改映射或使用错误的聚合? (刚从2.x更新到5.1)
答案 0 :(得分:23)
您需要在window.clipsToBounds = YES
子字段上汇总,如下所示:
keyword
这将有效。
答案 1 :(得分:1)
添加到@ Val的答案,您还可以在映射过程中将fielddata
设置为true:
"answer": {
"type": "text",
"fielddata": true, <-- add this line
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
答案 2 :(得分:1)
在聚合中,只需添加关键字即可回答。它对我有用。对于文本字段,我们需要添加关键字。 &#34; field&#34;:&#34; answer.keyword&#34;