elasticsearch索引创建问题适用于Linkedin WhereHows安装

时间:2018-05-12 00:17:09

标签: elasticsearch

完成安装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文件保存映射时出现类似错误。

有谁知道这里会发生什么以及如何解决?

1 个答案:

答案 0 :(得分:0)

通过安装5.6.9版本的elasticsearch(https://www.elastic.co/downloads/past-releases/elasticsearch-5-6-9)解决了这个问题。然后运行像

这样的东西
curl -XPUT localhost:9200/wherehows \
    -H "Content-Type: application/json" \
    -d @wherehows-es-indexes.setup.json

(我将json映射保存在wherehows-es-indexes.setup.json文件中只是为了方便起见)。

显着弹性搜索版本> 5.x不支持多种类型映射(https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html#removal-of-types)(Linkedin WhereHows安装说明显然需要)。

也相关:https://www.elastic.co/support/eol

(我想知道WhereHows开发者是否对此做了什么)