Recurse query limiting the number of results - not based on depth


(CondeChocula) #1

I’m trying to make a query similar to this and having trouble finding any examples that combine @recurse with filtering on the relationships,

{ log (func: uid(x)) @recurse  
    name 
    parent      
}

Here parent has it self a name and that can recurse quite deep.

I get back a nested structure like

log{
  name: name1
  parent {
     name: name2
     parent {
       name: name3
    }
  }

I’d like to filter (ie, don’t want them returned) any part node on the tree that matches a name for example, but i only manage cut the tree on the first one that doesn’t match not getting any of the deeper nodes and doesn’t lose information about the shape of the graph, still want to keep know whose node is a parent of another.

It might be a data modelling problem in the first place but I wonder if that query is possible

Thanks.


(Michel Conrado) #2

Recurse query limiting the number of results

You can’t. Just depth.
BTW, you could try to use “first” on edges. But It would cost performance.

You can add a filter to an Edge. eg:

{ log (func: uid(x)) @recurse  
    name 
    parent @filter(Not eq(name, "something")) (first: 300)
}

This will be applied recursively.