繁体   English   中英

elasticsearch.js批量插入错误

[英]elasticsearch.js bulk insert error

我正在尝试使用javascript elasticsearch客户端插入/更新数据,但出现错误:

  {
    "error": {
      "root_cause": [
        {
          "type": "illegal_argument_exception",
          "reason": "Malformed action/metadata line [1], expected a simple value for field [_data] but found [START_OBJECT]"
        }
      ],
      "type": "illegal_argument_exception",
      "reason": "Malformed action/metadata line [1], expected a simple value for field [_data] but found [START_OBJECT]"
    },
    "status": 400
  }

这是正在发送的数据

esclient.bulk({
    body: [
        {
            "index":
            {
                "_index":"myindex",
                "_type":"movie",
                "_id":"1IEAEHNOIORANIT4SEOASNIE3HAETN2E...",
                "_data": 
                {
                    "title":"Title 2",
                    "description":"This should be updated with this new data.",
                    "score":1,
                    "suggest_title":"Title 2",
                    "img":"http://url.to.image/img.jpeg",
                    "genres":["Comedy"],
                    "release":"2015-01-07T23:00:00.000Z",
                    "language":"EN",
                    "provider":
                    {
                        "id":"InstaFilmFlixify",
                        "url":"http://www.InstaFilmFlixify.com/play?id=238412"
                    }
                }
            }
        }
    ]
})

出现在此代码向ES发出以下请求时:

 -> POST http://docker.me:9200/_bulk
  {
    "index": {
      "_index": "myindex",
      "_type": "movie",
      "_id": "1IEAEHNOIORANIT4SEOASNIE3HAETN2E...",
      "_data": {
        "title": "Title 2",
        "description": "This should be updated with this new.",
        "score": 1,
        "suggest_title": "Title 2",
        "img": "http://url.to.image/img.jpeg",
        "genres": [
          "Comedy"
        ],
        "release": "2015-01-07T23:00:00.000Z",
        "language": "EN",
        "provider": {
          "id": "InstaFilmFlixify",
          "url": "http://www.InstaFilmFlixify.com/play?id=238412"
        }
      }
    }
  }

我究竟做错了什么? 怎么了? 这可能是ES / ES适配器中的错误吗?


Elasticsearch 2.1版

我之前没有看过"_data"参数。 您从哪里得到使用它的想法?

看一下js客户端的文档。

无论如何,这应该为您工作:

esclient.bulk({
    body: [
        {
            "index":
            {
                "_index":"myindex",
                "_type":"movie",
                "_id":"1IEAEHNOIORANIT4SEOASNIE3HAETN2E...",
            }
        },
        {
            "title":"Title 2",
            "description":"This should be updated with this new data.",
            "score":1,
            "suggest_title":"Title 2",
            "img":"http://url.to.image/img.jpeg",
            "genres":["Comedy"],
            "release":"2015-01-07T23:00:00.000Z",
            "language":"EN",
            "provider":
            {
                "id":"InstaFilmFlixify",
                "url":"http://www.InstaFilmFlixify.com/play?id=238412"
            }
        }
    ]
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM