无法创建自定义分析器 elasticsearch

cannot create custom analyzer elaticsearch

我正在尝试在 elasticsearch 中创建自定义分析器。这是分析器

{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer" : "standard",
          "filter" : ["custom_stopper", "custom_stems", "custom_synonyms"]
        },
        "filter" : {
            "custom_stopper" : {
                "type" : "stop",
                "stopwords_path" : "analyze/stopwords.txt"
            },
            "custom_stems" : {
                "type" : "stemmer_override",
                "rules_path" : "analyze/stem.txt"
            },
            "custom_synonyms" : {
                "type" : "synonyms",
                "synonyms_path" : "analyze/synonym.txt"

            }
        }
        }
      }
    }
  }

但它抛出错误

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "analyzer [filter] must specify either an analyzer type, or a tokenizer"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "analyzer [filter] must specify either an analyzer type, or a tokenizer"
    },
    "status": 400
}

我哪里做错了?

filter 必须与 analyzer 处于同一级别。

结构看起来像这样:

{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "standard",
          "char_filter": [
            "custom_stopper",
            "custom_stems",
            "custom_synonyms"
          ]
        }
      },
      "filter": {
        "custom_stopper": {
          "type": "stop",
          "stopwords_path": "analyze/stopwords.txt"
        },
        "custom_stems": {
          "type": "stemmer_override",
          "rules_path": "analyze/stem.txt"
        },
        "custom_synonyms": {
          "type": "synonyms",
          "synonyms_path": "analyze/synonym.txt"
        }
      }
    }
  }
}