python - Elasticsearch - 使用按查询更新在 doc_type 上给出错误
问题描述
我正在尝试使用以下方法一次更新多个文档:
q = {
"script": {
"inline": "ctx._source.text.class='contact'",
"lang": "painless"
},
"query": {
"match": {
"name": "Contact.txt"
}
}
}
es.update_by_query(body=q, doc_type='document', index='index_name')
如果字段名'name'是'Contact.txt',我想更新它'text':{'class':'contact'}
但是我收到了错误
TypeError: update_by_query() got an unexpected keyword argument 'doc_type'
类型是文档,所以我很困惑。我尝试删除争论并得到另一个错误
elasticsearch.exceptions.TransportError: TransportError(500, 'script_exception', 'runtime error')
解决方案
好像您使用的是弹性版本 7.x。这不再需要doc_type
指定,因为在 7.x 中删除了映射类型。
以下应该有效:
es.update_by_query(body=q, index='index_name')
推荐阅读
- laravel - Livewire 电线:选择选项上的模型无法正常工作
- javascript - highcharts 端点到端点连接
- python - 如何在 Pyglet 中连续播放音乐(同时使用 tkinter)?
- gem5 - 带有最新 Gem5 版本 (21.0.0.0) 的 Nvmain
- quarkus - 更新本机 quarkus 中的实体时出现 Blaze Persistence Null Pointer Exception
- javascript - 这个例子中的 .html() d3.js 方法是如何工作的?
- vba - 何时使用 Private Sub,何时使用 Public Sub?
- javascript - 根据来自 json 的数据用颜色填充 d3.js 地图
- python - 如何找到每场比赛的总跑数(可以通过 match_id 和 innings 理解)
- python - TensorFlow 2 - NumPy 数值和数组是否会导致 TF 函数的新图表?