Hello,
I have two versions of a query, and I feel like they should return the same result. They don’t – and I hope someone can explain why.
query version 1:
{
var(func: eq(xids, "test@email.com")) {
A as ~audit.entity {
expand(_all_)
}
}
res(func: eq(xids, "test@email.com")) {
xids
phones @facets(confidence) {
phone.number
phone.ext
count(~audit.attribute @filter(uid(A)))
}
}
}
result:
{'res': [{'phones': [{'count(~audit.attribute)': 3,
'phone.ext': 456,
'phone.number': '123-555-5555',
'phones|confidence': 85}],
'xids': ['03D42343FMTDFM', 'test@email.com']}]}
query version 2:
{
res(func: eq(xids, "test@email.com")) {
xids
A as ~audit.entity
phones @facets(confidence) {
phone.number
phone.ext
count(~audit.attribute @filter(uid(A)))
}
}
}
result:
{'res': [{'phones': [{'count(~audit.attribute)': 0,
'phone.ext': 456,
'phone.number': '123-555-5555',
'phones|confidence': 85}],
'xids': ['03D42343FMTDFM', 'test@email.com']}]}
Notice 'count(~audit.attribute)'
in the first result is 3, but in the second it’s 0. They use the exact same node selection statement, shouldn’t they return the same node list for ~audit.entity
?
The goal of this query is as follows:
“Get me all of B that points to A then the count of C that points to B and also points to A”
I’m very much new to dgraph, so if there’s a way to do this more efficiently, I’d love to hear it. But either way, I’m interested in why these two queries give different results.
Thanks!