orientechnologies / orientdb-gremlin

TinkerPop3 Graph Structure Implementation for OrientDB
Apache License 2.0
91 stars 32 forks source link

Index not updated? #136

Open rtfpessoa opened 7 years ago

rtfpessoa commented 7 years ago

We just experienced a weird case where we are using an UNIQUE index with two properties and sometimes the query returns empty but if we remove the index the query returns the value. Seems like the index is not being updated correctly? Any ideas?

wolf4ood commented 7 years ago

hi @rtfpessoa

how can i reproduce it?

rtfpessoa commented 7 years ago

We are inserting a large quantity of data with the same structure as before, one class with two fields and then the two are used in the index. (in the future it can have more fields)


CREATE CLASS V_Class1 EXTENDS V;
CREATE PROPERTY V_Class1.field1 Long (MANDATORY TRUE);
CREATE PROPERTY V_Class1.field2 String (MANDATORY TRUE);
CREATE INDEX V_Class1_field1_field1_index ON V_Class1 (field1, field2) UNIQUE;

then we do this query before inserting a value in the db:

    graph.V.`match`(
      __.as("c").hasLabel("Class1"),
      __.as("c").has("field1", "value1"),
      __.as("c").has("field2", "value2")
    )
      .select[Vertex]("c")
      .headOption()

If we do not get the value we create the vertex. With the index "sometimes" it fails because is trying to insert a value that already exists.

wolf4ood commented 7 years ago

hi @rtfpessoa

which version are you using of the OrientDB Gremlin driver?

rtfpessoa commented 7 years ago

I think the latest version for orientdb 2 stable which is "com.michaelpollmeier" % "orientdb-gremlin" % "3.2.3.0"

Is there any more recent version?

wolf4ood commented 7 years ago

@rtfpessoa

Maybe it could be related to https://github.com/orientechnologies/orientdb-gremlin/issues/135

If you remove the index all works fine?

Is your importer MultiThread?

rtfpessoa commented 7 years ago

Maybe is related to 135. My importer is single threaded at the moment. Do you have any suggestions of more stable ways to interact with OrientDB from Java/Scala?

wolf4ood commented 7 years ago

@rtfpessoa

For now the support of multiple field index is not optimal Most of the work has been done in the develop branch for this driver. Since the official support will start with OrientDB 3.0 http://orientdb.com/orientdb-officially-supports-tinkerpop-3/

If you can provide some script to reproduce we can work on a fix in master branch

Otherwise you can use the Official JAVA APIs for OrientDB 2.2.x

https://orientdb.com/docs/2.2/Java-API.html

wolf4ood commented 7 years ago

@rtfpessoa

are you using gremlin-scala ?

rtfpessoa commented 7 years ago

I am currently using gremlin-scala