orientdb-gremlin icon indicating copy to clipboard operation
orientdb-gremlin copied to clipboard

Invalid results (missing vertices) with multi-field index

Open christinedraper opened this issue 7 years ago • 1 comments

I am creating a class and index as follows:

create class V_Entity extends V;
create property V_Entity.entityId STRING;
create property V_Entity.entityType STRING;
create index entity_index ON V_Entity (entityId, entityType) UNIQUE;

Then using the 3.2.3 driver via Gremlin console (connecting to 2.2.17 OrientDB server), I do:

t.addV("Entity").property("entityId", "entity1").property("entityType", "blah")

Doing any of:

t.V().hasLabel("Entity").has("entityId", "entity1")
t.V().has("entityType", "blah")
.V().hasLabel("Entity").has("entityId", "entity1").has("entityType", "blah")

returns the vertex, however:

t.V().hasLabel("Entity").has("entityType", "blah")
t.V().hasLabel("Entity").has("entityType", "blah").has("entityId", "entity1")

does not.

Worse, when running in Java I am getting duplicate record problems, which I think is because the code is not finding the existing vertex due to the above, and is then trying to create rather than update it.

I have discovered that adding an additional index:

create index type_index ON V_Entity (entityType) NOTUNIQUE;

appears to work around the problem, although I'd feel better if I understood why.

christinedraper avatar Mar 21 '17 22:03 christinedraper

Hi @calebbriggs

thanks for this issue. Let me try to reproduce it

Thanks

wolf4ood avatar Mar 22 '17 09:03 wolf4ood