我是OData服务的新手。我编写了一个查询来检索具有空值的特定字段。我在OData中构建查询并将其传递给弹性搜索以检索数据。但查询似乎无效。
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.
答案 0 :(得分:1)
答案 1 :(得分:0)
实现此目标的一种方法是使用特殊_missing_
字段名称创建query_string
query,如下所示:
{
"from": 0,
"size": 15,
"query": {
"query_string": {
"query": "_missing_:assignedToEM"
}
}
}
或者也应该使用NOT
运算符,如下所示:
{
"from": 0,
"size": 15,
"query": {
"query_string": {
"query": "NOT(assignedToEM:*)"
}
}
}