You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Elasticsearch配置自定义analyzer后测试提示找不到分析器如何解决

问题原因

你的报错由两处拼写错误导致:

  • 自定义分析器配置节点拼写错误:Elasticsearch 识别的分析器配置节点为美式拼写 analyzer,你当前配置中使用了英式拼写 analyser,导致 Elasticsearch 无法定位到你声明的 autocomplete 分析器。
  • 过滤器命名与引用不匹配:你定义的 edge_ngram 过滤器名称为 autcomplete_filter(缺失字母 o),但在分析器配置的 filter 列表中引用的是 autocomplete_filter,即便分析器节点拼写修正后也会触发过滤器找不到的报错。
修复步骤

已创建的索引无法直接修改 analysis 配置,需按以下步骤操作:

  1. 关闭 movies 索引
curl -XPOST "127.0.0.1:9200/movies/_close"
  1. 更新索引配置,修正两处拼写错误
curl -XPUT "127.0.0.1:9200/movies/_settings" -H "Content-Type: application/json" -d '
{
    "analysis": {
        "filter": {
            "autocomplete_filter": {
                "type": "edge_ngram",
                "min_gram": "1",
                "max_gram": "20"
            }
        },
        "analyzer": {
            "autocomplete": {
                "filter": [
                    "lowercase",
                    "autocomplete_filter"
                ],
                "type": "custom",
                "tokenizer": "standard"
            }
        }
    }
}'
  1. 重新打开 movies 索引
curl -XPOST "127.0.0.1:9200/movies/_open"
  1. 验证分析器效果
curl -XGET "127.0.0.1:9200/movies/_analyze?pretty" -H "Content-Type: application/json" -d '
{
    "analyzer": "autocomplete",
    "text": "Sta"
}'

操作完成后即可正常返回分词结果。

内容的提问来源于stack exchange,提问作者webmaster Chp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 10:24:04