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

Elasticsearch 8.6.2映射解析失败:自定义分析器未配置问题解决

Elasticsearch Python客户端导入映射报错解决方案

问题场景

使用Elasticsearch Python客户端执行以下代码导入映射:

es_mappings = {
    "settings": {
        "analysis": {
            "analyzer": {
                "my_analyzer": {
                    "tokenizer": "my_tokenizer"
                }
            },
            "tokenizer": {
                "my_tokenizer": {
                    "type": "edge_ngram",
                    "min_gram": 2,
                    "max_gram": 5,
                    "token_chars": [
                        "letter",
                        "digit"
                    ]
                }
            }
        }
    },
    "properties": {
        "id": {"type": "integer"},
        "name": {"type": "text", "analyzer": "my_analyzer"},
        "desc": {"type": "text", "analyzer": "my_analyzer"},
        "datetime_create": {"type": "date"},
        "site_name": {"type": "text"}
    }
}

response = es.indices.create(index="<INDEX_NAME>", mappings=es_mappings, ignore=400)

报错信息

执行后收到如下错误:

ObjectApiResponse({'error': {'root_cause': [{'type': 'mapper_parsing_exception', 'reason': 'Failed to parse mapping: analyzer [my_analyzer] has not been configured in mappings'}], 'type': 'mapper_parsing_exception', 'reason': 'Failed to parse mapping: analyzer [my_analyzer] has not been configured in mappings', 'caused_by': {'type': 'illegal_argument_exception', 'reason': 'analyzer [my_analyzer] has not been configured in mappings'}}, 'status': 400})

尝试使用put_mapping()和put_settings()方法均未生效。

后续尝试(编辑补充)

尝试拆分映射与设置,执行以下代码:

response = es.indices.create(index="<INDEX_NAME>", mappings=es_mappings, settings=es_settings, ignore=400)

但收到新错误:

'unknown setting [index.settings.analysis.tokenizer.my_tokenizer.max_gram] please check that any required plugins are installed, or check the breaking changes documentation for removed settings'

最终解决方法

移除JSON顶层的"settings"参数后,问题解决。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.29 07:42:34