opened 11:37AM - 05 Apr 20 UTC
closed 04:51AM - 21 Jul 20 UTC
priority/P3
area/querylang
status/accepted
status/needs-attention
area/indexes
Hello,
When using the count index at the query root, I regularly need to get …values lower than a threshold, **including** zero.
For instance, suppose I have products connected to suppliers and I’d like to known when there are not enough suppliers. I could use the following query:
```
{
me(func:lt(count(supplier), 3)) {
uid
product_name
}
}
```
But I will miss the products with 0 suppliers: the most important ones to me.
I could use a second query block with a filter not has(supplier) but it is no efficient as not using any index.
What about adding an option on @count index to also track 0 counts?
It could be tracked only for the types containing the predicates with those indexes.
For example :
```
type Product {
supplier
}
supplier: [uid] @count(zero) .
```
Original forum thread: https://discuss.hypermode.com/t/tracking-zero-counts/6235