我试图做这样的事情:
SELECT * FROM x WHERE __account_id = 5 AND __import_id IN [1,2,3]
这是我的ES查询:
body = {
"query": {
"filtered" : {
"filter" : {
"term" : {
"__account_id" : account.id,
"__import_id": [x['id'] for x in ingested_imports]
}
}
}
}
}
结果似乎仅在__account_id上过滤,但在__import_id上没有过滤。我做错了什么?
答案 0 :(得分:1)
您需要在term
查询中包含terms
和bool
过滤器,因为这两个子句必须匹配。
{
"query":{
"filtered":{
"filter":{
"bool":{
"must":[
{
"term":{
"__account_id":5
}
},
{
"terms":{
"__import_id":[1, 2, 3]
}
}
]
}
}
}
}
}