栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

NodeJs-ElasticSearch批量API错误处理

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

NodeJs-ElasticSearch批量API错误处理

任何一项行动的任何失败都不会影响其他行动。

从elasticsearch bulk api
的文档中:

对批量操作的响应是一个大型JSON结构,其中包含执行的每个操作的单独结果。单个操作的失败不会影响其余操作。

在来自Elasticsearch客户的

status
响应中,每个动作对应一个响应,以确定它是否失败。

例:

    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  }     }        ]}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/399477.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号