我使用elasticsearch客户端连接到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)我使用的是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后,开始收到警告。
发布于 2021-10-29 06:28:23
您正在尝试在关键字字段上设置分析器。Elasticsearch分析器文档位于页面顶部:
只有文本字段支持分析器映射参数。
您必须将字段的类型更改为文本,或者为关键字字段指定任何分析器。还可以使用正规化对关键字字段应用令牌筛选器。正如在弹性讨论页面上这个问题的答案中提到的。
您想要使用的trim令牌筛选器在兼容过滤器列表中没有显式提到,但我使用Kibana dev工具进行了尝试,它似乎有效:
PUT normalizer_trim
{
"settings": {
"analysis": {
"normalizer": {
"my_normalizer": {
"type": "custom",
"filter": ["lowercase", "trim"]
}
}
}
},
"mappings": {
"properties": {
"foo": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
}
}https://stackoverflow.com/questions/69763986
复制相似问题