Topics

Query not returning always the same result


Adrián Abalde Méndez <aabalde@...>
 

Hello,

I'm having a strange behaviour with janusgraph and I would like to post it here and see if anyone can give me some help.

The thing is that I'm doing a tree query for getting my graph data structured as a tree, and from there build the results I'm interested in. This query works fine, but the problem is that I don't get the same results every time. It doesn't have any sense that, if the graph is the same and hasn't changed, the query returns different trees, does it?

Both trees I'm getting are not very different between them. We have a node type called "group", and some other nodes hanging from this "groups" called "results", and is just that some times the tree comes with the results and others not, but it has always the "group" structure.

In case you want to know it, the query I'm performing is this one:


lmg.traversal().V(analysisVertex).out().emit().repeat(
                __.in().choose(
                        __.label().is(P.eq("result")),
                        __.where(__.has("analysisId", analysisId))
                )
        ).tree().next().getTreesAtDepth(3);


where starting from an "analysis" node, I filter the graph to just have a tree with the groups and the results with the analysisId I'm interested in.

I guess that is not a problem of the query itself, because when it has the results, it works fine. But I don't know why I am getting this strange inconsistent behaviour.

Any ideas about this? Thanks in advance :)

Best regards,
Adrian


hadoopmarc@...
 

Hi Adrian,

What happens if you rewrite the query to:

lmg.traversal().V(analysisVertex).out().emit().repeat(
                __.in().choose(
                        __.hasLabel("result"),
                        __.has("analysisId", analysisId),
                        __.identity()
                )
        ).tree().next().getTreesAtDepth(3);

I do not understand how leaving out the else clause leads to the random behavior you describe, but it won't hurt to state the intended else clause explicitly. If the else clause is not a valid case in your data model, you do not need the choose() step.

Best wishes,   Marc