2017-02-14 44 views
0

Elasticsearch:2.3.3elasticsearch _update_by_query不起作用

下面是我的命令序列

指數一份文件

POST test-index/doc 
{ 
    "name":"sahas" 
} 

檢索文檔

GET test-index/_search 
{ 
    "query": { 
    "match": { 
     "name": "sahas" 
    } 
    } 
} 

更新doc

POST test-index/doc/_update_by_query?name=subramanian 
{ 
    "query": { 
    "match": { 
     "name": "sahas" 
    } 
    } 
} 

更新

{ 
    "took": 9, 
    "timed_out": false, 
    "total": 1, 
    "updated": 1, 
    "batches": 1, 
    "version_conflicts": 0, 
    "noops": 0, 
    "retries": 0, 
    "failures": [] 
} 

的結果,但是當我再次查詢文檔,它沒有更新。 無論如何要弄清楚爲什麼更新不在這裏工作? 我錯過了一些愚蠢的東西?

欣賞任何輸入..

回答

1

您通過查詢更新不會修改源。您需要包含腳本才能這樣做:

POST test-index/doc/_update_by_query 
{ 
    "query": { 
    "match": { 
     "name": "sahas" 
    } 
    }, 
    "script": { 
    "inline": "ctx._source.name = 'subramanian'" 
    } 
}