Create Elasticsearch curl query for not null and not empty(“”)

后端 未结 12 980
陌清茗
陌清茗 2020-12-13 01:21

How can i create Elasticsearch curl query to get the field value which are not null and not empty(\"\"),

Here is the mysql query:

select field1 from          


        
12条回答
  •  隐瞒了意图╮
    2020-12-13 02:14

    Wrap a Missing Filter in the Must-Not section of a Bool Filter. It will only return documents where the field exists, and if you set the "null_value" property to true, values that are explicitly not null.

    {
      "query":{
         "filtered":{
            "query":{
               "match_all":{}
            },
            "filter":{
                "bool":{
                  "must":{},
                  "should":{},
                  "must_not":{
                     "missing":{
                        "field":"field1",
                        "existence":true,
                        "null_value":true
                     }
                  }
               }
            }
         }
      }
    }
    

提交回复
热议问题