【问题标题】:Elasticsearch : Root mapping definition has unsupported parameters index : not_analyzedElasticsearch:根映射定义具有不受支持的参数索引:not_analyzed
【发布时间】:2017-01-10 08:51:33
【问题描述】:

大家好,我正在尝试创建模式测试。

PUT /test
{
    "mappings": {
        "field1": {
            "type": "integer"
        },
        "field2": {  
            "type": "integer"
        },
        "field3": {
            "type": "string",
            "index": "not_analyzed"
        },
        "field4": {
            "type": "string",
            "analyzer": "autocomplete",
            "search_analyzer": "standard"
        }
    },
    "settings": {
        bla
        bla
        bla
    }
}

我收到以下错误

{
    "error": {
        "root_cause": [{
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters: [index : not_analyzed] [type : string]"
        }],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [featured]: Root mapping definition has unsupported parameters:  [index : not_analyzed] [type : string]",
        "caused_by": {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [index : not_analyzed] [type : string]"
        }
    },
    "status": 400
}

请帮我解决这个错误

【问题讨论】:

    标签: elasticsearch mapping


    【解决方案1】:

    你快到了,你只是错过了一些东西:

    PUT /test
    {
      "mappings": {
        "type_name": {                <--- add the type name
          "properties": {             <--- enclose all field definitions in "properties"
            "field1": {
              "type": "integer"
            },
            "field2": {
              "type": "integer"
            },
            "field3": {
              "type": "string",
              "index": "not_analyzed"
            },
            "field4,": {
              "type": "string",
              "analyzer": "autocomplete",
              "search_analyzer": "standard"
            }
          }
        }
      },
      "settings": {
         ...
      }
    }
    

    更新

    如果你的索引已经存在,你也可以像这样修改你的映射:

    PUT test/_mapping/type_name
    {
        "properties": {             <--- enclose all field definitions in "properties"
            "field1": {
              "type": "integer"
            },
            "field2": {
              "type": "integer"
            },
            "field3": {
              "type": "string",
              "index": "not_analyzed"
            },
            "field4,": {
              "type": "string",
              "analyzer": "autocomplete",
              "search_analyzer": "standard"
            }
        }
    }
    

    更新

    从 ES 7 开始,映射类型已被删除。您可以阅读更多详情here

    【讨论】:

    • 谢谢。是否可以创建没有 typename 的映射。我想插入没有 typename 的数据 {field1,field2 ....} 而不是 typeName{field1,field2 ...}
    • 好的,这里什么是test,什么是type_name?
    • test 是您的索引名称,type_name 是您的映射类型的名称。
    • 复制粘贴此代码。它给出错误:“类型”:“mapper_parsing_exception”,“原因”:“根映射定义具有不受支持的参数:[type_name : {properties={field1={type=integer}, field4,={search_analyzer=standard,analyzer=autocomplete , type=string}, field3={index=not_analyzed, type=string}, field2={type=integer}}}]"
    • 对我来说,type_name 不起作用。我正在使用 elasticsearch-oss:7.20 docker image
    【解决方案2】:

    我希望上述答案适用于弹性搜索

    我正在使用 Elastic search 7.0 和 Nest C# 最新版本(6.6)。 ES 7.0 的一些重大更改导致了此问题。这是因为我们无法指定文档类型,并且在 NEST 6.6 版本中他们使用的是 doctype。所以为了解决这个问题,直到 NEST 7.0 发布,我们需要下载他们的 beta 包

    请通过此链接修复它

    https://xyzcoder.github.io/elasticsearch/nest/2019/04/12/es-70-and-nest-mapping-error.html

    编辑: NEST 7.0 现已发布。 NEST 7.0 与 Elastic 7.0 一起使用。详情请见release notes here

    【讨论】:

      【解决方案3】:

      检查您的 Elastic 版本。

      我遇到这些问题是因为我查看了错误版本的文档。

      【讨论】:

        【解决方案4】:

        从 ES 7 开始,映射类型已被删除。您可以阅读更多详情here

        如果您使用的是 Ruby On Rails,这意味着您可能需要从您的模型或关注点中删除 document_type

        作为映射类型的替代方案,一种解决方案是为每个文档类型使用一个索引。

        之前:

        module Searchable
          extend ActiveSupport::Concern
        
          included do
            include Elasticsearch::Model
            include Elasticsearch::Model::Callbacks
            index_name [Rails.env, Rails.application.class.module_parent_name.underscore].join('_')
            document_type self.name.downcase
          end
        end
        

        之后:

        module Searchable
          extend ActiveSupport::Concern
        
          included do
            include Elasticsearch::Model
            include Elasticsearch::Model::Callbacks
            index_name [Rails.env, Rails.application.class.module_parent_name.underscore, self.name.downcase].join('_')
          end
        end
        

        【讨论】:

        • 正是我的问题!很高兴在花了 2 个小时阅读文档后,这很容易解决。
        【解决方案5】:

        我正在运行 Elastic Search 7.12 版

        当我运行以下命令时

        curl -H 'Content-Type: application/json' -XPUT 127.0.0.1:9200/movies?pretty -d '
        {
            "mappings" : {
                "movie": {
                    "properties" : {
                        "year" : { "type": "date" }
                    }
                }
            }   
        }'
        

        返回以下错误。

        {
          "error" : {
            "root_cause" : [
              {
                "type" : "mapper_parsing_exception",
                "reason" : "Root mapping definition has unsupported parameters:  [movie : {properties={year={type=date}}}]"
              }
            ],
            "type" : "mapper_parsing_exception",
            "reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [movie : {properties={year={type=date}}}]",
            "caused_by" : {
              "type" : "mapper_parsing_exception",
              "reason" : "Root mapping definition has unsupported parameters:  [movie : {properties={year={type=date}}}]"
            }
          },
          "status" : 400
        }
        

        为了缓解这种情况,请按如下方式修改查询中的 json。

        curl -H 'Content-Type: application/json' -XPUT 127.0.0.1:9200/movies?pretty -d '
        {
            "mappings" : {
                "properties" : {
                    "year" : { "type": "date" }
                }
            }   
        }'
        

        注意:移除了“movie”:{} 层。现在可以了。

        【讨论】:

          【解决方案6】:
          PUT /testIndex
          {
              "mappings": {
                  "properties": {     <--ADD THIS
                      "field1": {
                          "type": "integer"
                      },
                      "field2": {  
                          "type": "integer"
                      },
                      "field3": {
                          "type": "string",
                          "index": "not_analyzed"
                      },
                      "field4": {
                          "type": "string",
                          "analyzer": "autocomplete",
                          "search_analyzer": "standard"
                      }
                  }
              },
              "settings": {
                  bla
                  bla
                  bla
              }
          }
          

          这是一个我知道有效的类似命令:

          curl -v -H "Content-Type: application/json" -H "Authorization: Basic cGC3COJ1c2Vy925hZGFJbXBvcnABCnRl" -X PUT -d '{"mappings":{"properties":{"city":{"type": "text"}}}}' https://35.80.2.21/manzanaIndex
          

          上述 curl 命令的细分为:

          PUT /manzanaIndex
          {
              "mappings":{
                  "properties":{
                          "city":{
                              "type": "text"
                          }
                  }
              }
          }
          

          【讨论】:

            【解决方案7】:

            如果您在 Python 中使用 elasticsearch_dsl,则此错误可能只是表示您使用的库版本不正确。

            库版本对应Elasticsearch版本。

            所以如果你使用 Elasticsearch 7.x,elasticsearch_dsl 应该是 7.x 等等

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2019-09-06
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多