【问题标题】:elasticsearch index creation problems for Linkedin WhereHows installationLinkedin WhereHows 安装的 elasticsearch 索引创建问题
【发布时间】: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


    【解决方案1】:

    通过安装 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 文件中)。

    显然 elasticsearch 版本 > 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 的开发人员是否对此有所作为)

    【讨论】:

      猜你喜欢
      • 2017-01-16
      • 1970-01-01
      • 2017-03-26
      • 1970-01-01
      • 2020-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多