如何重新索引对象类型字段,如:
{
"Foo": {
"properties": {
"ID": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
字符串
到其文本表示:
{
"Foo": {
"type": "text",
"index": "false"
}
}
型
使用raw reindex,我得到一个错误:Can't get text on a START_OBJECT at 1:141
1条答案
按热度按时间lo8azlld1#
我有一个类似的问题,只发现了这个问题,所以这是我的解决方案后,一些挖掘。
源中的数据不是字符串,因此Elasticsearch将无法找到内容。您需要将内容扁平化并将'Foo'字段替换为扁平化的值。
字符串
请注意,您必须检查
ctx._source.Foo != null
,否则脚本将失败。如果'Foo'在另一个字段中,则需要检查整个层次结构,如
(ctx._source.Higher != null && ctx._source.Higher.Foo != null)
个