Which lists even duplicates. I also tried to @groupby(group_type) and then count/max, but that doesn’t seem to be a way forward if I want to also paginate the results. Is this even currently possible in Dgraph?
Actually I did not quite understand what u wanted, I spent some time trying to understand and simulate at the same time. But I do not think I’ve reached to any conclusion.
This was what I tried:
{
GET_USER as var(func: has(user))
test(func: uid(GET_USER)) {
uid
user
~group_owner (first:2) {
group_type }
}
}
I wanted to achieve the same as SELECT DISTINCT would accomplish in SQL. I want to select all groups where given users are group_owner, take all group_type from these groups and return ones with unique name. So with my original dataset (don’t change it, else it doesn’t make sense), I want to return only a, b, c. With the query from original post, it returns a, a, b, b, c.
From your example " _:c <group_type> “c1” ." isn’t linked with any user. So you’ll never get C.
In fact from your example I can not think of anything in relation to what you say. In other cases I would try to use “uid_in”, but in your Set I can not use it as you need. Then a set closer to reality would help to follow the logic and analyze whether can or can’t do.
Now I’m assigning a team and need to know what unique skills it’s gonna have. My other requirement is that those unique skills have to be paginable.
In SQL the query I need would be:
SELECT DISTINCT skill.name
FROM skill
LEFT JOIN person
ON person.id = skill.owner
WHERE person.name = 'Ondrej' OR person.name = 'Michel'
LIMIT 10
{
set {
# First we set Unique nodes for Skills
_:Skill_Java <skill_name> "Java" .
_:Skill_Dgraph <skill_name> "Dgraph" .
_:Skill_Python <skill_name> "Python" .
#Now we assign the users to that skills using your way to relate those
_:michel <person> "Michel" .
_:Skill_Java <skill_owner> _:michel .
_:Skill_Dgraph <skill_owner> _:michel .
_:ondrej <person> "Ondrej" .
_:Skill_Python <skill_owner> _:ondrej .
_:Skill_Dgraph <skill_owner> _:ondrej .
}
}
Thanks. That was my backup plan, but hoped it’d be possible to do this with strings as well. Are there are any plans to introduce this functionality in the future?
With your solution, it means I have to create unique nodes with skill names and use uids in the query to get the uniqueness. It means a slight complication which could be prevented if I could just list all unique strings (without creating any extra nodes) as I originally wanted. The same as SELECT DISTINCT would do in SQL.
Okay, I see. But this is how the paradigm of graphs databases works. I believe that this logic you want would never be implemented other than via user application (means your app).
Graphs DBs are completely distinct from what SQL would be. The idea is that something that isn’t related via edges is a “new/diff thing/obj”. That is, you would always have two “dgraphs” in the query response. Dgraph understands that each result is unique, even though the string is the same.
This could even be implemented, but has no strength to be. For it is another paradigm. This could even generate a lot of useless chunks in the way. Making a little hell to clean the DB or unnecessary disk usage.