【发布时间】:2022-07-05 16:38:25
【问题描述】:
将Python包elasticsearch从7.6.0更新到8.1.0后,在这行代码开始报错:
count = es.count(index=my_index, body={'query': query['query']} )["count"]
收到以下错误消息:
DeprecationWarning:“body”参数已弃用,将 在未来的版本中删除。而是使用单个参数。
count = es.count(index=ums_index, body={'query': query['query']} )["计数"]
我不明白如何使用上述“个别参数”。 这是我的查询:
query = {
"bool": {
"must":
[
{"exists" : { "field" : 'device'}},
{"exists" : { "field" : 'app_version'}},
{"exists" : { "field" : 'updatecheck'}},
{"exists" : { "field" : 'updatecheck_status'}},
{"term" : { "updatecheck_status" : 'ok'}},
{"term" : { "updatecheck" : 1}},
{
"range": {
"@timestamp": {
"gte": from_date,
"lte": to_date,
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd"
}
}
}
],
"must_not":
[
{"term" : { "device" : ""}},
{"term" : { "updatecheck" : ""}},
{"term" : { "updatecheck_status" : ""}},
{
"terms" : {
"app_version" : ['2.2.1.1', '2.2.1.2', '2.2.1.3', '2.2.1.4', '2.2.1.5',
'2.2.1.6', '2.2.1.7', '2.1.2.9', '2.1.3.2', '0.0.0.0', '']
}
}
]
}
}
在官方文档中,我找不到任何机会找到如何在新版本的 Elasticsearch 中传递我的查询的示例。
除了恢复到以前版本的 Elasticsearch 之外,可能有人对此情况有解决方案吗?
【问题讨论】:
标签: python elasticsearch