Reputation: 21
type("overlap-rule").sub(Graql.Token.Type.RULE)
.`when`(
and(
`var`("t1").isa("trip"),
`var`("t2").isa("trip"),
`var`("t1").neq(`var`("t2"))
)
).then(
`var`().isa("trip-overlap")
.rel("overlapped-trip", "t1")
.rel("overlapped-trip", "t2")
)
Gives an error:
match $o isa trip-overlap; get;
Error: UNKNOWN: Invalid state in variable predicate [[$t1 !== $t2]] with answer [[$t1/V4136][$t2/V4136]]: either a concept is missing or not an attribute.. Please check server logs for the stack trace.
But when trying to define the same rule in graql, everything works:
overlap-rule sub rule,
when {
$t1 isa trip;
$t2 isa trip;
$t1 != $t2;
}, then{
(overlapped-trip: $t1, overlapped-trip: $t2) isa trip-overlap;
};
ekg> match $o isa trip-overlap; get;
{$o id V81928216 (overlapped-trip: id V4136, overlapped-trip: id V4296) isa trip-overlap;}
Does neq not work as expected?
Upvotes: 1
Views: 44
Reputation: 450
There are actually two kinds of "not equals" in Graql! There is the !=
that you used in the graql rule definition, which states that two concepts cannot be the same.
There is another type of not equals, that is written !==
in the language itself, representing the comparison of attribute concept values!
The trick is that !==
is written using var1.neq(var2)
in the Java query builder, whereas !=
is written using var1.not(var2)
in the query builder ;)
Upvotes: 1