Support search-all function at root
Add search all function at root level, combined with filter-by-count, as following
{
director(id:_searchall_) @filter(gt(count(director.film), 100)) {
count(director.film)
name.en
}
}
all directors who have produced more than 100 movies will be returned.
I think a better way to represent this query would be:
{
director(func: gt(count(director.film), 100)) {
count(director.film)
name.en
}
}
The way i put it in the filter so we could do a range search like following, @filter support AND/OR by nature. And it's more consistent with current @filter syntax: we fetch all stuff, then filter out the ones fulfill our needs
{
director(id:_searchall_) @filter(gt(count(director.film), 100) and lt(count(director.film), 150)) {
count(director.film)
name.en
}
}
Using And and Or is a good point. We could still do:
{
director(func: gt(count(director.film), 100)) @filter(lt(count(director.film), 150)) {
count(director.film)
name.en
}
}
Other issues would be:
- We are fingerprinting
_searchall_and checking for the UID. So we need to make sure the user doesn't specify that UID and we don't assign that uid to any entity. - Also, if we are moving to this approach, we can remove
funcat root. As any function at root can be specified this way (Starting with all nodes and filtering what we need).
So we have to decide which approach we want to take.
- Point 1: Makes sense. However, reserve some keywords is fine for our implementation, just like uid will always be taken as object instead of scalar. I'm not that like searchall either, prefer director(id: *) which is more consistent with programming custom, and could be extend to reg in the future.
- Point 2: Agree. We can remove func, and how about take id as function, like director(id(...)). This way, all stuff will be consistent at root as the functions. We could accept reg as well. Concern is, what should be placed as function, what should be placed into @filter. Or just no need for @filter.
- I just don't want to separate gt(count()) and lt(count()) into 2 parts. They are a pair, we'll not using style like
if a > 10 {
if a < 20 {
}
}
Once you place function all around, it will just confuse users.
Closing this for now.