2017-02-14 43 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'" 
    } 
}