我正在尝试使用Elasticsearch python客户端来摄取到Elasticsearch的Map,代码如下。
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(),但是不起作用,怎么解决这个错误呢?先谢谢了
**EDIT:**我尝试将Map和设置分开,并使用
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'
1条答案
按热度按时间z5btuh9x1#
设置必须在其自己的参数中发送,而不是作为Map的一部分: