【问题标题】:New index creation with new mapping from previously existing index使用来自先前存在的索引的新映射创建新索引
【发布时间】:2019-01-12 22:07:49
【问题描述】:
{
  "someindex": {
    "aliases": {
      "somealias": {}
    },
    "mappings": {},
    "settings": {
      "index": {
        "number_of_shards": "5",
        "provided_name": "someindex",
        "creation_date": "1547325991414",
        "analysis": {
          "filter": {
            "autocomplete_filter": {
              "type": "edge_ngram",
              "min_gram": "1",
              "max_gram": "20"
            }
          },
          "normalizer": {
            "lowerCaseNormalizer": {
              "filter": [
                "lowercase"
              ],
              "type": "custom"
            }
          },
          "analyzer": {
            "standard": {
              "filter": [
                "lowercase",
                "autocomplete_filter"
              ],
              "type": "custom",
              "tokenizer": "standard"
            }
          }
        },
        "number_of_replicas": "1",
        "uuid": "9vrt0U90RWG-4MRQEIbj6w",
        "version": {
          "created": "6050499"
        }
      }
    }
  }
}

上面是我新创建的结构的结构。在我当前的设置中,我在当前索引上有一个名为 bookName 的属性,当前映射如下:

{
  "bookName": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256,
        "normalizer": "lowerCaseNormalizer"
      }
    }
  }
}

现在,当我尝试重新索引名为“someindex”的新索引并想为字段 bookName 插入新映射时,它给了我错误。”

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:  [mappings : {details={properties={suggest={type=completion}, bookName={type=text, analyzer=standard}}}}]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Root mapping definition has unsupported parameters:  [mappings : {details={properties={suggest={type=completion}, bookName={type=text, analyzer=standard}}}}]"
  },
  "status": 400
}

我已经尝试了所有方法,并且能够从头开始对随机数据进行测试。但是,我必须在我的项目中引入此功能,并且我已经准备好一个具有不同映射的弹性索引。移民让我很困扰。有人可以指导我如何实现这一目标的正确程序。

注意:我已经尝试了一切,搜索了 Elastic 文档和所有相关链接。我能够在新数据集上做到这一点,但迁移对我来说是真正的问题,因为我是这个领域的新手。

【问题讨论】:

  • 您如何尝试更新新索引的映射?
  • 什么时候出现错误?尝试更新映射或将文档编入索引时?
  • 我在尝试将映射放入新创建的索引时遇到此错误。

标签: elasticsearch autocomplete mapping reindex search-suggestion


【解决方案1】:

要更新索引的映射,您必须使用put mapping api。因此,要更新映射,请使用以下请求:

PUT someindex/_mappings/_doc
{
  "properties": {
    "bookName": {
      "type": "text",
      "fields": {
        "keyword": {
          "type": "keyword",
          "ignore_above": 256,
          "normalizer": "lowerCaseNormalizer"
        }
      }
    }
  }
}

请注意,我假设映射名称是_doc

【讨论】:

    猜你喜欢
    • 2018-11-08
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多