Search by null or not nulls

Sample docs

{
	"type":"car"
	"color":null,
	"id":"1"
	"doors":0
}

{
	"type":"car"
	"color":"black"
	"id":"2",
	"doors":null
}

The color is test and doors in a integer.

  1. I want to be able to find all car with no color defined or defined.
  2. I want to able to find all doors with no door defined or defined.

@dipen_patel Searching null values is something we don’t support yet, but is on our road map.

Until such a time, you could use boolean queries with the knowledge of all values “color” can take, and possible values for “doors”. Here’re examples …

  • match all cars with color not black (a disjunct for all colors you don’t want to match)
curl -XPOST -H "Content-type:application/json" http://<username>:<password>@<ip>:8094/api/index/<index_name>/query -d '{"query": {"must": {"conjuncts": [{"match": "car", "field": "type"}]}, "must_not": {"disjuncts": [{"match": "black", "field": "color"}]}}}'
  • match all cars with color black (a disjunct for all colors you want to match)
curl -XPOST -H "Content-type:application/json" http://<username>:<password>@<ip>:8094/api/index/<index_name>/query -d '{"query": {"must": {"conjuncts": [{"match": "car", "field": "type"}, {"field": "color", "match": "black"}]}}}'
  • to match all cars with a defined set of doors (assuming that doors takes a positive value here)
curl -XPOST -H "Content-type:application/json" http://<username>:<password>@<ip>:8094/api/index/<index_name>/query -d '{"query": {"must": {"conjuncts": [{"match": "car", "field": "type"}, {"field": "doors", "min": 0, "inclusive_min": true}]}}}'
  • to match all cars where doors isn’t defined …
curl -XPOST -H "Content-type:application/json" http://<username>:<password>@<ip>:8094/api/index/<index_name>/query -d '{"query": {"must": {"conjuncts": [{"match": "car", "field": "type"}]}, "must_not": {"disjuncts": [{"field": "doors", "min": 0, "inclusive_min": true}]}}}'