2016-06-09 4 views
4

하나 이상의 동작에서 Elastic Bulk API가 실패하면 어떤 일이 발생하는지에 대한 문서를 찾을 수 없습니다. 예를 들어, 다음 요청에 대해 이미 id가 "3"인 문서가 있다고 가정하면 "만들기"가 실패해야합니다. 다른 모든 작업이 실패합니다?NodeJs-ElasticSearch 대량 API 오류 처리

{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } 
{ "field1" : "value1" } 
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } } 
{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } } 
{ "field1" : "value3" } 
{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "index1"} } 
{ "doc" : {"field2" : "value2"} } 
  • 나는 nodejs에게 탄성 모듈을 사용하고 있습니다.

답변

4

한 번의 작업에서 오류가 발생해도 다른 작업에는 영향을주지 않습니다. elasticsearch 벌크 API의 documentation 가입일

:

벌크 동작에 대한 응답 수행 된 각 액션의 개별 결과 큰 JSON 구조이다. 단일 작업이 실패해도 나머지 작업에는 영향을주지 않습니다.

client.bulk({ 
     body: [ 
     // action description 
     { index: { _index: 'test', _type: 'test', _id: 1 } }, 
     // the document to index 
     { title: 'foo' }, 
     // action description 
     { update: { _index: 'test', _type: 'test', _id: 332 } }, 
     // the document to update 
     { doc: { title: 'foo' } }, 
     // action description 
     { delete: { _index: 'test', _type: 'test', _id: 33 } }, 
     // no document needed for this delete 
     ] 
    }, function (err, resp) { 
     if(resp.errors) { 
      console.log(JSON.stringify(resp, null, '\t')); 
     } 
    }); 

응답 :

{ 
     "took": 13, 
     "errors": true, 
     "items": [ 
       { 
         "index": { 
           "_index": "test", 
           "_type": "test", 
           "_id": "1", 
           "_version": 20, 
           "_shards": { 
             "total": 2, 
             "successful": 1, 
             "failed": 0 
           }, 
           "status": 200 
         } 
       }, 
       { 
         "update": { 
           "_index": "test", 
           "_type": "test", 
           "_id": "332", 
           "status": 404, 
           "error": { 
             "type": "document_missing_exception", 
             "reason": "[test][332]: document missing", 
             "shard": "-1", 
             "index": "test" 
           } 
         } 
       }, 
       { 
         "delete": { 
           "_index": "test", 
           "_type": "test", 
           "_id": "33", 
           "_version": 2, 
           "_shards": { 
             "total": 2, 
             "successful": 1, 
             "failed": 0 
           }, 
           "status": 404, 
           "found": false 
         } 
       } 
     ] 
} 
elasticsearch 클라이언트로부터 응답

는 실패 여부

본보기를 결정하기 위해 각 동작에 대응하는 답변 status 존재

+0

resp.errors === true - resp.items가 본문에서 보낸 순서와 동일한 순서로 정렬됩니다. 대량 요청? –

+1

예. 동일한 순서입니다. – keety