我正在尝试过滤掉 Elasticsearch 查询以创建 Pandas 数据框。我在应用过滤器的数据框中有两列“类型”和“api”。当我将一列用作条件时,它工作正常..:-
result_dict = es.search(index="logstash-2018.08.11-alias",
body={"from": 0, "size": 10000,"query":
{"term" : {"type":"vx_apache_json"}}})
但是当我应用如下多个条件时:-
result_dict = es.search(index="logstash-2018.08.11-alias", body={"from": 0, "size": 1000,"queries": [
{ "term" : {"type" :"vx_apache_json"}},
{ "term" : {"api" :"viv_signin.php"}}
]})
我收到以下错误:-
RequestError:RequestError(400,“parsing_exception”,“[查询]中START_ARRAY的未知键。”)
有人可以在这里帮我吗,例如我可以在 Elasticsearch 中添加多重过滤。
最佳答案
试试下面的代码:
result_dict = es.search(index="logstash-2018.08.11-alias", body={"from": 0, "size": 1000,"query": {
"constant_score" : {
"filter" : {
"bool" : {
"must" : [
{ "term" : { "type" :"vx_apache_json" } },
{"term" :{ "api" :"viv_signin.php" }}
]
}
}
}
}
}
)
并且以相同的方式继续添加过滤器。
关于python - 在python中过滤以进行 Elasticsearch ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51972126/