I'm having trouble trying to create and use indexed types in Titan using ElasticSearch. I'm using Titan Server 0.4.0 and have a groovy script that does the following:
Sets the configuration:
config.setProperty("storage.backend","cassandra") config.setProperty("storage.hostname","127.0.0.1")
config.setProperty("storage.index.elastic.backend","elasticsearch") config.setProperty("storage.index.elastic.directory","db/es") config.setProperty("storage.index.elastic.client-only","false") config.setProperty("storage.index.elastic.local-mode","true")
create vertex and edge properties:
g.makeKey("property1").dataType("type").indexed("elastic",Vertex.class).make() g.makeKey("property2").dataType("type").indexed("elastic",Vertex.class).make()
Load vertices and edges from separate CSV files:
new File("path-to-csv").each({ line -> (property1,property2) = line.split(",")
v = bg.addVertex(id)
v.setProperty("property1",property1)
v.setProperty("property2",property2) })
Whenever I ignore the loop in step 3 and simply add sample vertices/edges/properties using the gremlin console it seems to work fine. However, when I run this in a groovy script (which takes a vertices and edges csv file and loads the data into Titan) I get the following error:
javax.script.ScriptException: com.thinkaurelius.titan.core.TitanException: Could not commit transaction due to exception during persistence
Research on this error implies it is an issue with resource locking, concurrent property setting or unique properties however I am not using any of these in my code. It seems unusual how it works when I type them in manually but breaks when I run it in the script - is it possible the script may be overtaking itself and trying to assign a value to a property (step 3) before setting up the property index in part 2?
Thanks, Adam