The RDF above is for sending Ethereum from address with UID 1 to address with UID 2 through transaction with UID 3. I have omitted non-relevant scalar predicates.
I need to scan graph N levels from the address of interest. Let’s say I sent something, I want to see where it went then. I can build a query by nesting levels, like that:
me(func: eq(address, "0x13b0e7e1d01b2678659a83a3d83fb60e1e594892")) {
from {
timestamp
to {
address
from {
timestamp
to {
address
}
}
}
}
}
However, I need to farther filter this query by adding a condition that in chain (addressA)-[from]->(trx1)-[to]->(addressB)-[from]->(trx2)-[to]->(addressC), timestamp of trx2 must be greater than timestamp of trx1. Is it doable with GraphQL? I have read about variable propagation, but cannot see how it can be used in my task. I understand that I can define a variable which will have timestamp of transactions of the first level:
var(func: eq(address, "0x13b0e7e1d01b2678659a83a3d83fb60e1e594892")) {
from {
t as timestamp
}
}
me(func: uid(t)) {
val(t)
to {
address
}
}
But how do I propagate value of timestamp scalar predicate down to nested level? Is there a concept of a parameter to a function, so that I won’t hardcode address in my function, but rather pass address predicate to a function call?
But I did not quite understand the second part. But I make it clear that you can use filters with Recurse Query. However below is a link to k-shortest-path-queries. That may be useful.
unfortunately for now dgraph needs index for all eq, gt and other operations, so it reads all values from that index that are greater than 1512534503, and then uses this list.
issue is described here: https://github.com/dgraph-io/dgraph/issues/2713
possible workarounds:
use facets. filter by facets doesn’t require index and works as you want. it works but it looks ugly. example is posted in that issue above
Nikita, thank you! Facets helped with performance a lot. Query which was taking 190 seconds now takes 19 with the same result. However, with facets for some reason query with parameters ceased to work from Java:
This one is not working, returning empty dataset. If I hardcode parameters in query string, it works, however in this case I suspect I spend too much time on parsing? With filter on predicate instead of facet, parameters have been working. Again I’m doing something wrong?