elasticsearch - 使用curl命令将JSON数据发布到 Elasticsearch

标签 elasticsearch

我正在尝试将Json文件发布到 Elasticsearch 中并面临以下错误

curl -XPOST http://localhost/test-index/doc -H "Content-Type: application/json" -d @test.json

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [test-index] as the final mapping would have more than 1 type: [_doc, doc]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [test-index] as the final mapping would have more than 1 type: [_doc, doc]"},"status":400}

test.json内容
{
  "name":"John Smith",
   "age":"38"

}


我错过了什么吗

最佳答案

要使用curl命令将Json数据发布到elasticsearch,可以尝试以下命令:

curl -XPOST http://localhost:9200/test-index/_doc -H "Content-Type: application/json" -d @test.json

enter image description here

您尝试发布Json文件的命令在Postman中可以正常使用。

enter image description here

关于elasticsearch - 使用curl命令将JSON数据发布到 Elasticsearch ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60714443/

相关文章:

elasticsearch - ElasticSearch-如何从动态字段元数据查询查询?

python - Elasticsearch 查询在 Python 中使用 httplib 给出 "No handler for uri"

Elasticsearch - 删除索引并重新创建索引

elasticsearch - Elasticsearch查询以查找字符串字段上的完全匹配项(无需分析)

elasticsearch - 无法使用Searchkit连接到Elasticsearch

c# - 接口(interface)上带有嵌套 ElasticType 的 ElasticSearch

json - 有没有办法查看查询是否与Elasticsearch中的数组中的任何元素匹配?

ruby-on-rails - 使用 ElasticSearch + Tire 搜索多个术语

elasticsearch - 通用策略类型返回

elasticsearch - Elasticsearch (1.6) 无法在带有 jdk1.7.0_71 的 Windows 7 上启动