How do I find Grakn 2.0 entities that lack an attribute of a specific type?

124 Views Asked by At

I am running Grakn 2.0.0-alpha in a docker container. I have a hypergraph representing a state machine, with state transitions between states.

Some of these transitions have an attribute of type some-attribute-type, and some do not. I can confirm this by querying for all transitions and checking them one by one. However, when I use negation in the following query, I get nothing. What am I doing wrong? I have tried the following query both via the Python client and via the console.

match {
$next (preceding $current_state, succeeding $next_state) isa next;
 { 
   not {
    $next has some-attribute-type $g0;
   };
 };
};

The grakn 2.0.0-alpha negation may have a bug or the semantics may have diverged from the prior major release. It appears that if you try to first match a variable against the type you want to negate, and then use that variable to check the non-existence, then you get too many matches (as expected)

The following query returns some results, but more than expected from the previous query.

match {
$next (preceding: $current_state, succeeding: $next_state) isa next;
  $e isa some-attribute-type;
   not {
   $next has $e;
  };
};

See the following bug report: https://github.com/graknlabs/grakn/issues/6034

1

There are 1 best solutions below

0
On

Can you provide a simple reproducible example, please?

Also, is that possible that you forgot to close the write transaction?