eliasdb icon indicating copy to clipboard operation
eliasdb copied to clipboard

Query not returning expected result

Open TcM1911 opened this issue 4 years ago • 2 comments

I have a graph where 4 nodes (T1 through T4) are connected like this:

[T1] <-(E2)- [T2] <-(E3)- [T3] -(E4)-> [T4]

The goal of my query is:

Given a T1, find the T4 items.

The kind for T1, T2 and T3 are known but the type for T4 is not. For some reason the follwing query does not work (traversing from the left to right: T1 to T2 to T3 to T4).

get T1 where key = "%s"
    traverse in:E2:out:T2
        traverse in:E3:out:T3
            traverse out:E4:in:
            end
        end
    end

Traversing the nodes and edges in reverse works fine (Right to left).

get T4 where key = "%s"
    traverse in:E4:out:T3
        traverse out:E3:in:T2
            traverse out:E2:in:
            end
        end
    end
show 4:n:key

If I instead start on a node for T2, traverse to T1 and check the contstraint, followed by traversing T2 to T3 to T4 works fine.

get T2
    traverse out:E2:in:T1 where key = "%s"
    end 
    traverse in:E3:out:T3
        traverse out:E4:in:
        end
    end

Alternative, if a use full wildcards for the second and the third traversal, T4 is returned (plus some extra data...)

get T1 where key = "%s"
    traverse in:E2:out:T2
        traverse :::
            traverse :::
            end
        end
    end
show 4:n:key

I can't see why the first query doesn't work. Given that traversing in the reverse works, suggests that the graph is correct. Any idea what the issue is?

TcM1911 avatar Jan 02 '22 20:01 TcM1911

Hey there,

I am not able to reproduce the issue. I've added a test which attempts to test this scenario (see eql/regression_test.go for "Issue 43").

The result of the query is:

Labels: T1 Key, T1 Name, T2 Key, T2 Name, T3 Key, T3 Name, Key, Kind, Name Format: auto, auto, auto, auto, auto, auto, auto, auto, auto Data: 1:n:key, 1:n:name, 2:n:key, 2:n:name, 3:n:key, 3:n:name, 4:n:key, 4:n:kind, 4:n:name t1, T1 node, t2, T2 node, t3, T3 node, t4, T4, T4 node

I would expect this result. Could you have a look if I made a mistake or if the failing scenario needs some further conditions to show the unexpected result?

krotik avatar Jan 03 '22 14:01 krotik

Thanks @krotik. The test looks right. I'll see if I can write some code that I can share that replicates the code I have and reproduces the same issue. It may take a few days until I can get to it though.

TcM1911 avatar Jan 04 '22 01:01 TcM1911