2017-07-28 73 views
0

这是我的数据...Elasticsearch:存在的过滤掉不工作

{"score":60,"name":"bill"}, 
{"score":50,"name":"john"}, 
{"score":null,"name":"sam"} 

我期待写一个过滤范围查询,这也应该包括空值。

我试过这个...期待所有3个结果,但它返回0结果...?

"filter": { 
      "bool": { 
       "must": [ 
       { 
        "range": { 
        "score": { 
         "lte": 100 
        } 
        } 
       }, 
       { 
        "exists": { 
        "field": "score" 
        } 
       } 
       ] 
      } 
      } 

任何帮助是非常赞赏... 感谢

+0

你可以粘贴bool/should返回消息呢? – MedAli

+0

@MedAli不知道你是什么意思?没有错误....它只是返回0结果 – Slyper

回答

1

你需要做的是,有或者您的range查询或丢失score

{ 
    "query": { 
    "bool": { 
     "should": [ 
     { 
      "range": { 
      "score": { 
       "lte": 100 
      } 
      } 
     }, 
     { 
      "bool": { 
      "must_not": { 
       "exists": { 
       "field": "score" 
       } 
      } 
      } 
     } 
     ] 
    } 
    } 
} 
+0

有没有这个运气? – Val