dgraph icon indicating copy to clipboard operation
dgraph copied to clipboard

Support search-all function at root

Open squalfof opened this issue 9 years ago • 5 comments

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.

squalfof avatar Feb 22 '17 11:02 squalfof

I think a better way to represent this query would be:

{
  director(func: gt(count(director.film), 100)) {
    count(director.film)
    name.en
  }
}

ashwin95r avatar Feb 23 '17 00:02 ashwin95r

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
  }
}

squalfof avatar Feb 23 '17 01:02 squalfof

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 func at 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.

ashwin95r avatar Feb 23 '17 01:02 ashwin95r

  • 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.

squalfof avatar Feb 23 '17 02:02 squalfof

Closing this for now.

pawanrawal avatar Mar 17 '17 06:03 pawanrawal