加入字段(Multi-type 索引错误)- Elasticsearch

Join field (Multi-type index error) - Elasticsearch

我想创建一个带有 'join' 字段的索引。我使用了 ES 文档提供的准确的 curl 命令:

curl -X PUT "localhost:9200/my_index" -H 'Content-Type:                 
application/json' -d'
{
  "mappings": {
    "_doc": {
      "properties": {
        "my_join_field": { 
          "type": "join",
          "relations": {
            "question": "answer" 
          }
        }
      }
    }
  }
}
'

这是导致的错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Failed to parse mapping [_doc]: cannot create join field [my_join_field] on multi-types index [my_index]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [_doc]: cannot create join field [my_join_field] on multi-types index [my_index]",
    "caused_by" : {
      "type" : "illegal_state_exception",
      "reason" : "cannot create join field [my_join_field] on multi-types index [my_index]"
    }
  },
  "status" : 400
}

我正在努力理解错误(并努力修复它),因为我指定了一个没有其他类型的新索引。如果我misspoke/mistyped,请不要犹豫纠正我:D

Edit:这个命令运行时使用的版本是5.6.11,但我目前正在尝试运行6.4.1。我不确定这是否会修复错误。

Edit: 问题标题已更新。

好的,这就是交易。

我上面列出的版本似乎没有加入字段本身,所以我选择升级。我是通过 运行 以下命令完成的:

  1. echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
  2. sudo apt-get update
  3. sudo apt-get install elasticsearch

嘻嘻,又是一个浪费时间的问题。

T. Okai

Join 字段可以在 ElasticSearch5 上使用,只要您在索引设置中将 mapping.single_type 设置为 true。 (比照https://www.elastic.co/guide/en/elasticsearch/reference/5.6/parent-join.html#parent-join

您还必须重命名文档类型名称,因为它不能以“_”开头。