Let's say I have the following data
{
fruit: "Mango",
cost : 2.00,
variety : "alphanso",
},
{
fruit : "apple",
cost : 1.40,
variety : "Gala"
},
{
fruit : "apple",
variety : "cosmic crisp",
},
{
fruit : "apple",
variety : "honey crisp",
cost : 2.99
}
I am looking for a search that returns apples with a cost between 1 and 2 and also returns the variety that doesn't have a cost field set.
In this case, the result will contain "Gala" and "cosmic crisp"
Start with the complete set of documents, *:*
, subtract those that have a value [* TO *]
, and add those that match variety:Gala
.
q=(*:* -cost:[* TO *]) OR variety:Gala