elasticsearch,Json,Http,Ubuntu,Curl,elasticsearch" /> elasticsearch,Json,Http,Ubuntu,Curl,elasticsearch" />

将JSON/XML/TXT/CSV文件发送到ElasticSearch

将JSON/XML/TXT/CSV文件发送到ElasticSearch,json,http,ubuntu,curl,elasticsearch,Json,Http,Ubuntu,Curl,elasticsearch,我一直在尝试将各种格式的数据发送到我的计算机上运行的ElasticSearch 我正在运行Ubuntu17(最新版本),但无法运行 以下是我在终端上使用的命令: curl -X POST 'http://localhost:9200/json/test/2' -d @json.json 我在文件所在的正确目录中。下面是我得到的错误: {"error":"Content-Type header [application/x-www-form-urlencoded] is not sup

我一直在尝试将各种格式的数据发送到我的计算机上运行的ElasticSearch

我正在运行Ubuntu17(最新版本),但无法运行

以下是我在终端上使用的命令:

curl -X POST 'http://localhost:9200/json/test/2' -d @json.json     
我在文件所在的正确目录中。下面是我得到的错误:

{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
我在网上搜索过,但没有结果


我做错了什么?

你可以这样做:

curl -XPUT 'localhost:9200/twitter/tweet/1?pretty' -H 'Content-Type: application/json' -d'
{
    "user" : "kimchy",
    "post_date" : "2009-11-15T14:12:12",
    "message" : "trying out Elasticsearch"
}
'

由于未将内容类型指定为JSON,请求未通过的原因。另外,您应该使用PUT而不是POST:)我从以下文档复制了此请求:。干杯。

您看到的错误是由于弹性搜索的版本不同。在
-XPUT
之前,添加
-H'内容类型:application/json'

以下是一个例子:

curl -H 'Content-Type: application/json' -XPUT 127.0.0.1:9200/

现在我从终点站得到这个。{“错误”:{“根本原因”:[{“类型”:“映射器解析异常”、“原因”:“未能解析”}],“类型”:“映射器解析异常”、“原因”:“未能解析”、“原因”:“{”类型”:“非内容解析异常”、“原因”:“只能对某些xcontent字节或压缩的xcontent字节”},“状态”:400}curl:(6)无法解析主机:应用程序curl:(6)无法解析主机:json_products。jsonI不确定我是否遵循。谢谢。因此,我从这个新添加的内容中了解到,强制执行
http.content_type。从版本6.0.0开始,要求
为true