from elasticsearch import Elasticsearch
es = Elasticsearch()
es.indices.create(index='report', ignore=400)
es_reponse = es.index(index='reports',doc_type='text',body=report_json)
我正进入(状态
RequestError(400, 'illegal_argument_exception', 'mapper [table.rows.endDate] of different type, current_type [date], merged_type [text]')
此错误,可以通过将index.mapping.ignore_malformed设置为false来解决:但是,我不知道在代码中的哪里指定?
我正在使用
elasticsearch 7.0.5
最佳答案
您可以在Python
中使用以下参数创建索引:
from elasticsearch_dsl import Index
from elasticsearch import Elasticsearch
es=Elasticsearch(['ES_URL:ES_PORT'])
index = Index('my_index', es)
index.settings(
number_of_shards=6,
number_of_replicas=2,
index={'mapping':{'ignore_malformed':False}}) //or True
index.create()
这就是
Elasticsearch
上的样子:[root@host]$ curl -XGET ES_URL:ES_PORT/my_index/_settings?pretty
{
"my_index" : {
"settings" : {
"index" : {
"mapping" : {
"ignore_malformed" : "false"
},
"number_of_shards" : "6",
"provided_name" : "my_index",
"creation_date" : "1573646292390",
"number_of_replicas" : "2",
"uuid" : "e__BuX-KSSeoR2LXQXaWkA",
"version" : {
"created" : "6020499"
}
}
}
}
}
关于python - 如何在elasticsearch python低级客户端中指定index.mapping.ignore_malformed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58835485/