I was playing around with Recurse Query and wanted to return all names in one level.
The query looks like this:
{
recurse(func: gt(count(~genre), 30000), first: 1) {
allUids as _uid_
name@en
~genre (first:10) @filter(gt(count(starring), 2))
starring (first: 2)
performance.actor
}
q (func: uid(allUids)) {
name@en
}
}
However, I wasn’t able to add var to recurse query to hide it’s result in the output. I tried:
recurse var(func: gt(count(~genre), 30000), first: 1) {
var recurse(func: gt(count(~genre), 30000), first: 1) {
Also, query result “q” contains only performance.actor names - genre names for example are left out.
The actual reason for this is that I need to perform a recursive delete and I thought that when I can get all these necessary uid values, then I can delete them.
Perhaps there is better option to delete recursively?
pawan
(Pawan Rawal)
November 10, 2017, 1:31am
2
Hey @rait.raidma
I have an open PR Make recurse a directive by pawanrawal · Pull Request #1754 · dgraph-io/dgraph · GitHub to make recurse
a directive. That would allow you to use it with a var
root.
What you are doing seems correct regarding deleting nodes recursively. I will have to check why all names are not being returned and get back to you.
Something else I noticed is that this query only returns genre names.
{
recurse(func: gt(count(~genre), 30000), first: 2) {
names as name@en
~genre (first:10) @filter(gt(count(starring), 2))
starring (first: 2)
performance.actor
}
q (func: uid(names)) {
name@en
}
}
And when I changed the first query by adding @cascade , then it helped to get rid of the values in recurse array.
recurse(func: gt(count(~genre), 30000), first: 1) @cascade {
returned
{
"data": {
"recurse": [],
"q": [
// ...
system
(system)
Closed
December 10, 2017, 12:31pm
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.