使用Elasticsearch的批量API时出现mapper_parser_exception

txu3uszq  于 2022-12-03  发布在  ElasticSearch
关注(0)|答案(1)|浏览(258)

ElasticSearch版本:8.3.3
使用以下Elasticsearch API执行索引。

curl -X POST "localhost:9200/bulk_meta/_doc/_bulk?pretty" -H 'Content-Type: application/json' -d' 
{"index": { "_id": "1"}}
{"mydoc": "index action, id 1 "}
{"index": {}}
{"mydoc": "index action, id 2"}
'

在这种情况下,发生了以下错误。

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "Malformed content, found extra data after parsing: START_OBJECT"
    }
  },
  "status" : 400
}

我看到帖子要求添加\n,但没有帮助。

jpfvwuh4

jpfvwuh41#

您需要从请求中删除_doc

curl -X POST "localhost:9200/bulk_meta/_bulk?pretty" -H 'Content-Type: application/json' -d'
{"index":{"_id":"1"}}
{"mydoc":"index action, id 1 "}
{"index":{}}
{"mydoc":"index action, id 2"}
'

相关问题