Hi,
I’m new to dgraph and consider it as a replacement of neo4j.
I have a network graph with ip addresses and domains. The schema looks like this:
type Domain {
name
<has_a_record>
<has_aaaa_record>
<has_ns_record>
<~has_ns_record>
<has_mx_record>
<~has_mx_record>
<has_parent>
<~has_parent>
<~has_ptr_record>
}
type IP {
name
<~has_a_record>
<~has_aaaa_record>
<has_ptr_record>
}
I want to traverse a graph and check the degree (a number of edges connected to a node) of each vertex on every step. If some vertex has the degree exceeding the threshold value it must not be expanded.
When I use just one predicate (<has_a_record> for instance) the query is straightforward:
{
find(func: eq(name, "google.com")) @recurse(depth: 5, loop: false) {
name
has_a_record @filter(lt(count(~has_a_record), 100))
~has_a_record @filter(lt(count(has_a_record), 100))
}
}
But I want to use all predicates of a type. Expand query seemed suitable but the documentation says that the result of this query can only be filtered by a node type.
It is possible to mention all the predicates in a query:
{
f(func: eq(name, "google.com")) @recurse(depth: 5, loop: false) {
name
has_parent
~has_parent @filter(lt(count(has_parent), 100))
has_a_record @filter(lt(count(~has_a_record), 100))
~has_a_record @filter(lt(count(has_a_record), 100))
has_aaaa_record @filter(lt(count(~has_aaaa_record), 100))
~has_aaaa_record @filter(lt(count(has_aaaa_record), 100))
has_ns_record @filter(lt(count(~has_ns_record), 100))
~has_ns_record @filter(lt(count(has_ns_record), 100))
has_mx_record @filter(lt(count(~has_mx_record), 100))
~has_mx_record @filter(lt(count(has_mx_record), 100))
has_ptr_record @filter(lt(count(~has_ptr_record), 100))
~has_ptr_record @filter(lt(count(has_ptr_record), 100))
}
}
However, it is not a convinient approach. And moreover it counts a degree considering only one predicate.
Is there an another method?
Thanks!