Find data with long when is null

How is possible find a data when a long value is null?

I try to do this, but an error occurs:

{
   "query":{
      "bool":{
         "must":[
            {
               "term":{
                  "account":123
               }
            },
            {
               "term":{
                  "codoperator":null
               }
            }
         ]
      }
   },
   "size":10000,
   "sort":{
      "name":{
         "order":"asc"
      }
   }
}

This is the error:

{
   "error":{
      "root_cause":[
         {
            "type":"illegal_argument_exception",
            "reason":"field name is null or empty"
         }
      ],
      "type":"illegal_argument_exception",
      "reason":"field name is null or empty"
   },
   "status":400
}

Try a bool query with must_not clause containing an exist query.

That should work

Thanks @dadoonet, the must_not work.

The final code:

{
   "query":{
      "bool":{
         "must":[
            {
               "term":{
                  "account":123
               }
            }
         ],
         "must_not":{
            "range":{
               "codoperator":{
                  "gte":1
               }
            }
         }
      }
   },
   "size":10000,
   "sort":{
      "name":{
         "order":"asc"
      }
   }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.