代码之家  ›  专栏  ›  技术社区  ›  Karthikeyan

弹性搜索错误:自定义分析器[custom_analyzer]在名称[my_tokenizer]下找不到标记器

  •  0
  • Karthikeyan  · 技术社区  · 7 年前

    我想和我的 custom_analyzer &安培 tokenizer 但我犯了一些错误。

    请在下面找到映射字段时从Kibana获取的错误

    Custom Analyzer [custom_analyzer] failed to find tokenizer under name [my_tokenizer]

    请查找我的地图详细信息。

    PUT attach_local
        {
            "settings": {
            "analysis": {
              "analyzer": {
                "custom_analyzer": {
                  "type": "custom",
                  "tokenizer": "my_tokenizer",
                  "char_filter": [
                    "html_strip"
                  ],
                  "filter": [
                    "lowercase",
                    "asciifolding"
                  ]
                }
               }
              }
            },
            "tokenizer": {
            "my_tokenizer": {
              "type": "ngram",
              "min_gram": 3,    
              "max_gram": 3,
              "token_chars": [
                "letter",
                "digit"
              ]
            }
          },
    
          "mappings" : {
            "doc" : {
              "properties" : {
                "attachment" : {
                  "properties" : {
                    "content" : {
                      "type" : "text",
                      "analyzer": "custom_analyzer"
                    },
                    "content_length" : {
                      "type" : "long"
                    },
                    "content_type" : {
                      "type" : "text"
                    },
                    "language" : {
                      "type" : "text"
                    }
                  }
                },
                "resume" : {
                  "type" : "text"
                }
              }
            }
          }
        }
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Val    7 年前

    正确缩进json非常重要。你会发现你的标记器在 analysis 章节。以下是正确的定义:

    {
      "settings": {
        "analysis": {
          "analyzer": {
            "custom_analyzer": {
              "type": "custom",
              "tokenizer": "my_tokenizer",
              "char_filter": [
                "html_strip"
              ],
              "filter": [
                "lowercase",
                "asciifolding"
              ]
            }
          },
          "tokenizer": {
            "my_tokenizer": {
              "type": "ngram",
              "min_gram": 3,
              "max_gram": 3,
              "token_chars": [
                "letter",
                "digit"
              ]
            }
          }
        }
      },
      "mappings": {
        "doc": {
          "properties": {
            "attachment": {
              "properties": {
                "content": {
                  "type": "text",
                  "analyzer": "custom_analyzer"
                },
                "content_length": {
                  "type": "long"
                },
                "content_type": {
                  "type": "text"
                },
                "language": {
                  "type": "text"
                }
              }
            },
            "resume": {
              "type": "text"
            }
          }
        }
      }
    }