0

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:

  1. 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")

  2. 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()

  3. 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

adaml288
  • 61
  • 1
  • 6
  • Can you verify, that you don't have any invalid values? I haven't tested it, but I suspect that Titan/ES will also throw this exception when you try to insert empty strings. – Daniel Kuppitz Jan 03 '14 at 22:28
  • Hi Daniel, thanks for the reply. I commented out the code that sets the actual properties and I still get the same error, so unfortunately I don't think this is the problem. – adaml288 Jan 08 '14 at 10:46
  • Just to add - I ran the script in the Gremlin console and discovered that it throws this error on the line: v = bg.addVertex(value). The stack trace tells me that "no type specified for property" which appears to be an error with the ElasticSearch capability. Perhaps I'm using this command in the wrong way? I didn't actually change this line from before when I didn't have specific property keys and it worked fine. – adaml288 Jan 08 '14 at 10:52
  • Okay, I've narrowed it down and it gets even more confusing. the bg.addVertex(value) loops through a csv file containing IP addresses, and by printing the output it seems to load in the first 1000 from the file and then error. No matter how I edit the list, the IP it errors at is always on line 1001. – adaml288 Jan 08 '14 at 11:27
  • "bg" sounds like you're using BatchGraph and BatchGraph seems to commit the batch after 1000 entries. What's really weird is that you get the same error without setting any property. Can you share the full code somewhere, maybe in a Gist? – Daniel Kuppitz Jan 08 '14 at 14:01
  • Hi, thanks for pointing that out. I had another look at my code and found the line: bg = new BatchGraph(g, VertexIDType.STRING, 1000) Which at the time I copied from some sample code and wasn't aware of the "1000" parameter. I increased the batch size and now it works! – adaml288 Jan 09 '14 at 10:39

0 Answers0