当尝试添加映射与dynamic_templates具有analyzer和search_analyzer时发出警告.<



我正在使用elasticsearch python客户端连接到elasticsearch.

当尝试添加映射到索引时,我得到以下警告:

es.indices.put_mapping(index=index, body=mappings)
/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py:209: ElasticsearchWarning: }}], attempted to validate it with the following match_mapping_type: [string], caused by [unknown parameter [search_analyzer] on mapper [__dynamic__attributes] of type [keyword]]
/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py:209: ElasticsearchWarning: }}], attempted to validate it with the following match_mapping_type: [string], caused by [unknown parameter [search_analyzer] on mapper [__dynamic__metadata] of type [keyword]]
warnings.warn(message, category=ElasticsearchWarning)

当索引记录时,得到这个警告:

/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py:209: ElasticsearchWarning: Parameter [search_analyzer] is used in a dynamic template mapping and has no effect on type [keyword]. Usage will result in an error in future major versions and should be removed.
warnings.warn(message, category=ElasticsearchWarning)
/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py:209: ElasticsearchWarning: Parameter [analyzer] is used in a dynamic template mapping and has no effect on type [keyword]. Usage will result in an error in future major versions and should be removed.
warnings.warn(message, category=ElasticsearchWarning)

我正在使用using elasticsearch "7.15.1">

pip包:

elasticsearch = = 7.15.1

elasticsearch-dsl = = 7.4.0

我的设置和映射是:

settings = {"analysis": {"analyzer": {"my_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": ["trim"]}
}
}
}
mappings = {"dynamic_templates": [
{"attributes": {
"match_mapping_type": "string",
"path_match": "attributes.*",
"mapping": {
"type": "keyword",
"analyzer": "my_analyzer",
"search_analyzer": "my_analyzer"
}
}
},
{"metadata": {
"match_mapping_type": "string",
"path_match": "metadata.*",
"mapping": {
"type": "keyword",
"analyzer": "my_analyzer",
"search_analyzer": "my_analyzer"
}
}
}
]
}

我需要帮助调整映射,这个映射在弹性6.0.1上工作得很好。升级到7.15.1后出现警告

您正在尝试在关键字上设置分析器字段。Elasticsearch分析器文档在页面顶部声明:

文本字段支持分析器映射参数。

您必须将字段的类型更改为文本,或者根本不为关键字字段指定分析器。还可以使用规范化程序将令牌过滤器应用于关键字字段。正如Elastic讨论页上这个问题的答案所提到的。

您想要使用的修剪令牌过滤器在兼容过滤器列表中没有明确提到,但我在Kibana开发工具中尝试了它,它似乎有效:

PUT normalizer_trim
{
"settings": {
"analysis": {
"normalizer": {
"my_normalizer": {
"type": "custom",
"filter": ["lowercase", "trim"]
}
}
}
},
"mappings": {
"properties": {
"foo": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
}
}

相关内容

  • 没有找到相关文章

最新更新