具有弹性搜索的OData服务

时间:2015-10-17 03:54:11

标签: elasticsearch odata

我是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.

2 个答案:

答案 0 :(得分:1)

使用Olastic - Elasticsearch的OData服务的开源实现 您可以使用源代码作为示例,或者从maven

获取依赖关系

答案 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:*)"
        }
    }
}