Anijit Sau
Anijit Sau

Reputation: 575

using UPSERT create edges but in vertex class it shows nothing in Orientdb

UPDATE GeoAgentSummary set out = #45:0, in = #21:0, _2015 = sum(_2015, 10.0f) upsert where out = #45:0 and in = #21:0

I am using the above query to either create an edge (if it is not there) or update an existing edge if it already exists in OrientDB

An edge is created between #45:0 and #21:0.

But in Agent(vertex class having clusters 45, 46, 47 and 48) i.e. in #45:0 it is not showing any outgoing edges.

Agent Class a vertex class

Upvotes: 0

Views: 196

Answers (2)

Maklyura
Maklyura

Reputation: 21

I know that this question is three years old, but for somebody else who will google it further:

You can use “upsert” for edges since version 3.0.1 and it will work properly – but you need to do the following:

Create unique index on edge_class (out, in) and – it's strange – The order is important! To do this, you need to create in and out properties first, otherwise db can't create index and there will be an exception when you will try to run command “Create index”. Then, use command CREATE EDGE UPSERT FROM TO .

In this case edge will be created only if it is not exists, and it will create in and out properties for vertex classes.

But it still doesn't work for UPDATE command 'cos, as authors said, “The UPDATE/UPSERT works at document level, so it doesn't create the connections from the vertices. Using it, you will have a broken graph” and it still the same.

Upvotes: 1

Ivan Mainetti
Ivan Mainetti

Reputation: 1982

The UPDATE command acts like a normal document update without taking care of keeping the edge-vertex "synchronization". To do that you'd have to use the UPDATE EDGE that, however, doesn't support the UPSERT.

There is on open issue on github about that https://github.com/orientechnologies/orientdb/issues/4436


Read also this https://github.com/orientechnologies/orientdb/issues/1114

Upvotes: 0

Related Questions