Andrew Bracker Andrew Bracker - 1 year ago 77
Java Question

Graql insert query: duplicate Var objects

Var message = var().isa("message");

Var relation = var().isa("connection")
.rel("role1", id("existing-id"))
.rel("role2", message);

Executing the following creates two instances of a message.

Is this expected? If it is, is it because I did not assign an ID, or because I have used two insert statements?

Answer Source

This is the expected behaviour. You're correct at guessing that assigning an id will solve the issue:

Var message = var().id("my-message").isa("message");

The reason this happens is because a Var does not represent a single concept. Instead, it represents a pattern to match in the graph. In this instance, the Var only says "things that are messages", not any particular message.

You could also assign a variable name, e.g. Var message = var("x"). ... For this to work, you would have to execute only a single insert.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download