Uid variable behaviour unexpected

I have 3 kinds of nodes: miid node, dev node and login node.
2 kinds of edges: miid <miid.login> login; dev <dev.login> login. BOTH have reverse edges.

in fact it is in essence simply miid dev. Making login as nodes facilitates indexing on the login properties.

Now starting with a set of miids, I want to find the subset of miids which have a common logged-in device with at least one other miid on the starting set, along with the devices that connects them.

startingset as var(func: has(miid.ovd_level.3))

quer(func: uid(startingset)) @ignorereflex @cascade{
~dev.login @filter(lt(count(dev.login), 100) ){
~miid.login @filter(uid(startingset)){
destmiids as miid: miid.miid
ovdmd: miid.ovd_max_days

ctt(func: uid(destmiids)){

The return graph of this query well fits my need, but I can’t understand the result of the count(uid) in ctt, which is much bigger than the number of returned nodes yet a bit smaller than the total number of miids in the starting set.

example mutation:
_:miid1 <miid.login> _:login1A .
_:devA <dev.login> _:login1A .
_:miid1 <miid.miid> “11111” .
_:devA <dev.id> “aaaaa” .

_:miid2 <miid.miid> “22222” .
_:devA <dev.login> _:login2A .
_:miid2 <miid.login> _:login2A .

_:miid3 <miid.miid> “33333” .
_:devB <dev.login> _:login3B .
_:miid3 <miid.login> _:login3B .
_:devB <dev.id> “bbbbb” .

_:miid4 <miid.miid> “44444” .

in this case I want to only return miid1, miid2, devA, login1A, login2A, and I want destmiids to be assigned only miid1, miid2

1 Like

I’ll see your question as soon as I have time, but if anyone is available to help feel free. I can supplement it if necessary.

Seems it’s only me…

@xinstein can you please share the response you got when you tried this query?

This question is really confusing and a lot of information is missing. At first it’s simple, but your query seems more complex than the example you presented.

I tried to simulate something approximate of your query and assimilate with the example presented. But I did not succeed.

It would be interesting to report what it means:

And give us more reproductive context.

This would be simple, you can use Kinds/Types or even a Type predicated indexed by Hash. But if your intention is otherwise, we need context. Maybe you want to filter by relation or something. It’s hard to know.

But I do not see relationship between miid1, miid2, devA, login1A, login2A. So you should use a type or some predicate with a specific reason.

as Karandeep says

or even more details like a similar schema.

Sorry for the incomplete information.

miid is the id of user accounts, dev is the id of devices,
this is a bipartite graph which miid only loggs in to devices, and devices are only logged in by miids, NO intra-type connection exists.

In principle there should be no login nodes, which are merely used to store what should in principle be stored as edge facets. But facets do not support indexing, while it’s sometimes useful to filter login timestamp.

I’m now trying to find all the miid’s which has at least one co-user (that is, one other miid which has shared the same device with the miid in consideration).

miid.ovd_level.3 is a user group which has severe overdue history.
miid.ovd_max_days is the max overdue days this user has commited.

@filter (lt (count (dev.login), 100) this is to filter abnormal devices, devices which has been logged in by more than 100 users are considered abnormal.

Oh right, I just noticed that I was confusing everything. LOL. (I simply ignored the count when I read it)

I’ll rerun this tomorrow, but give us a result example. With actual result and desired result.