【发布时间】:2018-05-12 00:17:08
【问题描述】:
完成安装 Linkedin 的 WhereHows 工具 (https://github.com/linkedin/WhereHows/blob/master/wherehows-docs/getting-started.md#elasticsearch-setup) 的安装步骤,在设置 elasticsearch 索引时遇到问题。
按照 tar 文件的 elasticsearch 安装说明 (https://www.elastic.co/guide/en/elasticsearch/guide/current/running-elasticsearch.html),一切似乎都设置好了:
curl 'http://localhost:9200/?pretty'
{
"name" : "TjtCCG8",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "LFsoqrBMSRCn80eHVWxYvw",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
然后运行命令
curl -XPUT '$YOUR_INDEX_URL:9200/wherehows' -d '
{
"mappings": {
"dataset": {},
"comment": {
"_parent": {
"type": "dataset"
}
},
"field": {
"_parent": {
"type": "dataset"
}
}
}
}
'
我们看到了错误
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
** 注意:我看过这个帖子,https://stackoverflow.com/a/48289099/8236733,但是以各种方式转义引用似乎并没有解决问题:
curl -XPUT 'localhost:9200/wherehows' -d '
{
\"mappings\": {
\"dataset\": {},
\"comment\": {
\"_parent\": {
\"type\": \"dataset\"
}
},
\"field\": {
\"_parent\": {
\"type\": \"dataset\"
}
}
}
}
'
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
curl -XPUT localhost:9200/wherehows -d "
{
\"mappings\": {
\"dataset\": {},
\"comment\": {
\"_parent\": {
\"type\": \"dataset\"
}
},
\"field\": {
\"_parent\": {
\"type\": \"dataset\"
}
}
}
}
"
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
为json添加内容头,我看到了错误
curl -XPUT 'localhost:9200/wherehows' -H "Content-Type: application/json" -d "
{
\"mappings\": {
\"dataset\": {},
\"comment\": {
\"_parent\": {
\"type\": \"dataset\"
}
},
\"field\": {
\"_parent\": {
\"type\": \"dataset\"
}
}
}
}
"
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [wherehows] as the final mapping would have more than 1 type: [field, comment, dataset]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [wherehows] as the final mapping would have more than 1 type: [field, comment, dataset]"},"status":400}
(应该注意这里说的是“拒绝映射更新”,但实际上索引实际上还没有)。使用 json 文件保存映射时出现类似错误。
有谁知道这里会发生什么以及如何解决它?
【问题讨论】:
标签: elasticsearch