【问题标题】:Elasticsearch error while mapping - unknown setting映射时出现 Elasticsearch 错误 - 未知设置
【发布时间】:2021-03-06 06:04:19
【问题描述】:

我正在尝试使此代码正常工作,但出现以下错误: 参考:https://www.youtube.com/watch?v=PQGlhbf7o7c

请告诉我如何解决此问题。谢谢。

代码:

PUT test
{
  "settings": {
    "index": {
      "analysis": {
        "filter": {},
        "analyzer": {
          "keyword_analyzer": {
            "filter": [
              "lowercase",
              "asciifolding",
              "trim"
            ],
            "char_filter": [],
            "type": "custom",
            "tokenizer": "keywords"
          },
          "edge_ngram_analyzer": {
            "filter": [
              "lowercase"
            ],
            "tokenizer": "edge_ngram_tokenizer"
          },
          "edge_ngram_search_analyzer": {
            "tokenizer": "lowercase"
          },
          "tokenizer": {
            "edge_ngram_tokenizer": {
              "type": "edge_ngram",
              "min_gram": 2,
              "max_gram": 5,
              "token_chars": [
                "letter"
              ]
            }
          }
        }
      }
    },
    "mappings": {
      "properties": {
        "name": {
          "type": "text",
          "fields": {
            "keywordstring": {
              "type": "text",
              "analyzer": "keyword_analyzer"
            },
            "edgengram": {
              "type": "text",
              "analyzer": "edge_ngram_analyzer",
              "search_analyzer": "edge_ngram_search_analyzer"
            },
            "completion": {
              "type": "completion"
            }
          },
          "analyzer": "standard"
        }
      }
    }
  }
}

错误

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "unknown setting [index.mappings.properties.name.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings",
    "suppressed" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.completion.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.edgengram.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.edgengram.search_analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.edgengram.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.keywordstring.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.fields.keywordstring.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      },
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [index.mappings.properties.name.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      }
    ]
  },
  "status" : 400
}

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    你快到了,但创建索引时的有效负载结构应该是这样的:

    PUT test
    {
      "settings": {
        "analysis": {
           ...
        }
      },
      "mappings": {
        "properties": {
           ...
        }
      }
    }
    

    在你的情况下,这意味着:

    PUT test
    {
      "settings": {
        "analysis": {
          "filter": {},
          "analyzer": {
            "keyword_analyzer": {
              "filter": [
                "lowercase",
                "asciifolding",
                "trim"
              ],
              "char_filter": [],
              "type": "custom",
              "tokenizer": "keywords"
            },
            "edge_ngram_analyzer": {
              "filter": [
                "lowercase"
              ],
              "tokenizer": "edge_ngram_tokenizer"
            },
            "edge_ngram_search_analyzer": {
              "tokenizer": "lowercase"
            },
            "tokenizer": {
              "edge_ngram_tokenizer": {
                "type": "edge_ngram",
                "min_gram": 2,
                "max_gram": 5,
                "token_chars": [
                  "letter"
                ]
              }
            }
          }
        }
      },
      "mappings": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keywordstring": {
                "type": "text",
                "analyzer": "keyword_analyzer"
              },
              "edgengram": {
                "type": "text",
                "analyzer": "edge_ngram_analyzer",
                "search_analyzer": "edge_ngram_search_analyzer"
              },
              "completion": {
                "type": "completion"
              }
            },
            "analyzer": "standard"
          }
        }
      }
    }
    

    【讨论】:

    • 嗨 @Joe 更新我的代码。添加此代码后,它会引发另一个错误。我已经添加了上面的错误。请让我知道我该如何解决?提前致谢
    • 明天会做,但请编辑问题而不是答案。
    • 当然!谢谢。也请你也请检查这个Q!我真的很感谢你的帮助!!再次感谢 - stackoverflow.com/questions/66497829/…
    • 你发现 tokenizer 错误了吗?
    • 是的@Joe。谢谢
    猜你喜欢
    • 1970-01-01
    • 2021-12-22
    • 2012-01-06
    • 1970-01-01
    • 1970-01-01
    • 2014-11-27
    • 2018-03-30
    • 1970-01-01
    • 2017-02-23
    相关资源
    最近更新 更多