我正在使用 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)
我正在使用使用彈性搜索“7.15.1”
pip 包:
彈性搜索==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 后開始收到警告。
uj5u.com熱心網友回復:
您正在嘗試在關鍵字欄位上設定分析器。該Elasticsearch分析檔案頁面的頂部指出:
只有文本欄位支持分析器映射引數。
您必須將欄位的型別更改為文本或根本不為關鍵字欄位指定分析器。您還可以使用規范化器將令牌過濾器應用于關鍵字欄位。正如Elastic 討論頁面上這個問題的答案中提到的那樣。
兼容過濾器串列中未明確提及您要使用的修剪令牌過濾器,但我使用 Kibana 開發工具進行了嘗試,它似乎有效:
PUT normalizer_trim
{
"settings": {
"analysis": {
"normalizer": {
"my_normalizer": {
"type": "custom",
"filter": ["lowercase", "trim"]
}
}
}
},
"mappings": {
"properties": {
"foo": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/345197.html
