2017-01-03 110 views
0

我儘量做到批量更新Elasticsearch 5.1批量操作

方法:郵政 網址:/客戶/外部/ _bulk

Json的身體:

{"index":{"_id":"1"}} 
{"name": "John Doe" } 
{"index":{"_id":"2"}} 
{"name": "Jane Doe" } 

Id 1已更新,但id 2未更新。我不知道爲什麼?

響應是在這裏:

{ 
    "took": 138, 
    "errors": false, 
    "items": [ 
    { 
     "index": { 
     "_index": "customer", 
     "_type": "external", 
     "_id": "1", 
     "_version": 15, 
     "result": "updated", 
     "_shards": { 
      "total": 2, 
      "successful": 1, 
      "failed": 0 
     }, 
     "created": false, 
     "status": 200 
     } 
    } 
    ] 
} 
+0

你是否確定在第四行後添加一行? – Val

回答

1

正如@val提到的,你應該在你的身體json在最後一行的末尾換行符\n

{"index":{"_id":"1"}} 
{"name": "John Doe" } 
{"index":{"_id":"2"}} 
{"name": "Jane Doe" }\n 

按在bulk_api中提到。希望能幫助到你!

+0

現在工作。感謝 – user5510975

+0

感謝@Val指出它。很高興幫助! – Kulasangar