python - 如何在 elasticsearch python 低级客户端中指定 index.mapping.ignore_malformed?
问题描述
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','不同类型的映射器[table.rows.endDate],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"
}
}
}
}
}
推荐阅读
- asp.net - 在 web.config 中访问域以 root 的规则
- python - 如何将线程概念用于我的 update() 函数而不是 root。after() ,这样它就不会干扰 tkinter 窗口
- flutter - Firestore 在颤动中为不同的文档发送相同的图像
- c# - 图像opencvsharp中的阈值深度距离c#intel realsense
- system.reactive - Rx.Net - 订阅 Cold Observable 时,发布方法缺少前几项
- javascript - 在刷新中格式化日期和时间
- javascript - 如何在两个详细信息元素上设置属性和删除属性?
- c# - 在 Razor 页面中的 OnGet 方法之后刷新 div 内容
- entity-framework-core - Entity Framework Core 2.2 嵌套选择生成多个查询
- php - 多个 Laravel 项目 htaccess