So, I've been struggling for a while with a problem that looked simple but for which I just cannot find a solution. At this point I'm not sure if it's not possible to do this, or if I'm just unable to see it. Let's see if anyone can think of a way to solving this!
The thing is, I have an index with one entry (one document) per item sold in a particular store. So, for a given store, I have many independent entries. For instance:
Store: "John's veggies", Item: "carrots"
Store: "John's veggies", Item: "tomatoes"
Store: "John's veggies", Item: "eggplant"
Store: "Vegan World", Item: "carrots"
Store: "Vegan World", Item: "oranges"
Store: "Vegan World", Item: "squash"
... and so on.
The thing is, I need to answer questions such as:
How many stores do NOT sell eggplant? (in this case, a simple query such as "NOT Item: eggplant" would not work, because it would return for instance 'Store: "John's veggies", Item: "carrots"', which would add to the count and would not be correct.
How many stores sell carrots and oranges? (in this case, a simple query such as "Item: carrots AND Item: oranges" would not work, because "Item" cannot have two values and the result is zero documents. Another option such as "Item: carrots OR Item: oranges" would not work, because it would return stores that have either one or the other but would not match both conditions, being independent documents).
So, at the beginning this looked super simple but I just can't see a way to do it. What am I missing?
Thanks a lot for your help!