I am new to OData services.I have written a query to retrieve the specific field with null values.I build the query in OData and pass it on to elastic search to retrieve data.But the query seems to be not working.
The query is as follows:
$filter=assignedToEM eq null.
I have also tried giving as:
$filter=assignedToEM eq 'null'
The query has been built as :
{
"from" : 0,
"size" : 15,
"query":{
"bool" : {
"must_not" : {
"term" : {
"assignedToEM" : "null"
}
}
}
}
}
In elastic search schema,The not_null value for assignedToEM is given as "null".
It would be really helpful if i get a solution for this as soon as possible. Thanks.
One way to achieve this would be to create a query_string
query with the special _missing_
field name instead, like this:
{
"from": 0,
"size": 15,
"query": {
"query_string": {
"query": "_missing_:assignedToEM"
}
}
}
Or what should also work is to use the NOT
operator like this:
{
"from": 0,
"size": 15,
"query": {
"query_string": {
"query": "NOT(assignedToEM:*)"
}
}
}