我正在尝试过滤掉不为 null 的值:
以sql为例
SELECT ALL FROM Mytable WHERE field_1 NOT NULL and field_2 ="alpha"
我应该如何在 elasticsearch-dsl(python) 中编写此查询?
我试过这样的事情:
s = Mytable.search().query(
Q('match', field_2 ='alpha')
).filter(~Q('missing', field='field_1'))
但它返回具有 field_1 空值的元素
另外,我试过这个,但没有用
field_name_1 = 'field_2'
value_1 = "alpha"
field_name_2 = 'field_1'
value_2 = " "
filter = {
"query": {
"bool": {
"must": [
{
"match": {
field_name_1 : value_1
}
},
{
"bool": {
"should": [
{
"bool": {
"must_not": [
{
field_name_2: {
"textContent": "*"
}
}
]
} }
]
}
}
]
}
}
}
白猪掌柜的
忽然笑
DIEA
相关分类