sqlalchemy-elasticquery
sqlalchemy-elasticquery copied to clipboard
How to do "is NULL"/"is NOT NULL" query?
I have tried
filter = {
'filter': {
'deleted_on': None
}
}
# Err - UnboundLocalError: local variable 'operator' referenced before assignment
filter = {
'filter': {
'deleted_on': {
'is': None
}
}
}
filter = {
'filter': {
'deleted_on': 'is_null'
}
}
@hussaintamboli hey, take a look here
I have tried that with
filter = {
'filter': {
'deleted_on': 'is_null'
}
}
But the query formed has
User.deleted_on = NULL
Instead of
User.deleted_on is NULL
You have to change these lambda functions.
from
'is_null': lambda f: f is None,
'is_not_null': lambda f: f is not None,
to
'is_null': lambda f: f.is_(None),
'is_not_null': lambda f: f.isnot(None),
@christopher11 true, do you want to send a PR?
change
from
'is_null': lambda f: f is None,
'is_not_null': lambda f: f is not None,
to
'null': lambda f, a: f.is_(None) if a else f.isnot(None)
use
filter = {
'field': {
'null': true // or false
}
}
its work