Python 弹性搜索与查询
我正在尝试这样做:Python 弹性搜索与查询,python,elasticsearch,Python,elasticsearch,我正在尝试这样做: SELECT * FROM x WHERE __account_id = 5 AND __import_id IN [1,2,3] 以下是我的问题: body = { "query": { "filtered" : { "filter" : { "term" : { "__account_id" : account.id,
SELECT * FROM x WHERE __account_id = 5 AND __import_id IN [1,2,3]
以下是我的问题:
body = {
"query": {
"filtered" : {
"filter" : {
"term" : {
"__account_id" : account.id,
"__import_id": [x['id'] for x in ingested_imports]
}
}
}
}
}
结果似乎只在uu帐户u id上过滤,而不在u导入u id上过滤。我做错了什么?您需要在
bool
查询中包装一个术语和术语
过滤器,因为这两个子句必须匹配
{
"query":{
"filtered":{
"filter":{
"bool":{
"must":[
{
"term":{
"__account_id":5
}
},
{
"terms":{
"__import_id":[1, 2, 3]
}
}
]
}
}
}
}
}
这是有道理的。我刚刚注意到,使用我的python客户机,它可以正常工作,但在kopf中不起作用。不知道是怎么回事。