Question

I'm trying to port my Neo4J application to Titan and I'm having some issues related to indexes. I understand that Titan does not support vertex or edge indexes, only "key" indexes, is it right?

I'm also working with Bulbs models, for example:

class Person(Node):
    element_type = 'person'
    facebook_id = String(indexed=True)

It should be possible when adding Person(facebook_id='111') to retrieve using:

gremlin> g.getVertices('facebook_id', '111')

It doesn't work and tells me that I need to create the key index before using it. So I dropped the keyspace and manually created the index in rexster doghouse:

gremlin> g.createKeyIndex("facebook_id", Vertex.class);

After that, created Person(facebook_id='111') with Bulbs and tried to retrieve on rexster doghouse:

gremlin> g.getVertices("facebook_id", "111")

And got empty response. When fetching using Titan vertex ID it works, but "facebook_id" comes empty and ".map()" doesn't work:

gremlin> g.v(4)
==>v[4]
gremlin> g.v(4).name
==>Renato Garcia Pedigoni
gremlin> g.v(4).facebook_id # nothing returned!
gremlin> g.v(4).map()
==>javax.script.ScriptException: java.lang.IllegalArgumentException: The value is already used by another vertex and the key is unique

PS

  • It's the first vertex I created after dropping the keyspace
  • Is it possible create keys indexes automatically?

Any tips?

Thanks!

Renato Pedigoni

Was it helpful?

Solution

Yes, Titan only supports key indexes which replace the old manual vertex indexes with similar functionality but less overhead.

The exception indicates that the property is not only indexed but also unique (see Titan Types for more information).

Have you tried adding the vertex and key index in Gremlin (i.e. without Bulbs)? Also, James has done a lot of work on Bulbs with respect to Titan integration, so this particular issue might be resolved in the most current version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top