使用update_by_query我們可以更新中存在的映射僅存的領域,或者我們可以能夠創建一個新的領域,在所有文件的值..使用update_by_query API更新多個文檔?
因爲我曾嘗試下面的查詢在所有文檔中創建一個新的領域在索引:
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"uniqueId": 805569568956
}
}
]
}
}
}
},
"script": {
"inline": "ctx._source.Univesity.Name.Region.Europe = 'UCLA'"
}
}
IT拋出這樣
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "failed to run inline script [ctx._source.Univesity.Name.Region.Europe = 'UCLA'] using lang [groovy]"
}
],
"type": "script_exception",
"reason": "failed to run inline script [ctx._source.Univesity.Name.Region.Europe = 'UCLA'] using lang [groovy]",
"caused_by": {
"type": "null_pointer_exception",
"reason": "Cannot get property 'Name' on null object"
}
},
"status": 500
}
在elasticsearch.yaml錯誤我配置以下屬性:
script.inline: true
script.indexed: true
script.engine.groovy.inline.aggs: on
script.engine.groovy.inline: true
我的映射是這樣的:
"mappings": {
"Univesity": {
"properties": {
"Name": {
"properties": {
"Region": {
"properties": {
"Europe": {
"type": "string"
}
"Australia": {
"type": "string"
}
}
},
在5.0.0和5.2中,我在下面編寫的查詢工作(在Windows和Linux上測試)。到目前爲止,因爲你沒有顯示所有的東西,我只能推斷你的「過濾」查詢或你的「丟失」查詢有什麼不對。 – Adonis
我根據你的反饋更新了我的問題。可以請你通過.. – Seeker