0

There seems to be plenty of documentation around creating a Vertex index in Titan:

mgmt.buildIndex('byNameAndLabel', Vertex.class).addKey(name)

I can't find much documentation about adding Edge indexes, e.g.:

mgmt.buildIndex('byNameAndLabel', Edge.class).addKey(name)

My questions:

  1. When is it appropriate to add an Edge index to a graph?
  2. Will an Edge index be used if it's available in any/all parts of a traversal or only the first time it's encountered?

The second question I guess is related to how the underlying store (in my case Cassandra) will use indexes. So the question is really "does the graph go back to the underlying store for each part of the traversal and how does that impact its use of indexes?"

Guy
  • 65,082
  • 97
  • 254
  • 325

2 Answers2

3

Edge indexes should only be vertex centric indexes, not global indexes. I no longer have a test environment for Titan, but I'm actually surprised, that this:

mgmt.buildIndex('byNameAndLabel', Edge.class).addKey(name)

...still works. I thought this was prevented since 0.5.x, because those indexes never behaved like users expected.

g.E().has("indexedProperty", value)

...can actually lead to long running scan operation. If I recall correctly, such an edge index stores the id of the edge's out-vertex and the edge id. So the query mentioned before would first load the out-vertex and then scan its edges until it finds the edge with the indexed id.

Daniel Kuppitz
  • 10,846
  • 1
  • 25
  • 34
  • Thanks Daniel - I didn't actually try the index builder with Edge.class - that was from some (I'm guessing old) docs that I was reading. – Guy Feb 11 '17 at 23:53
0

In my case, I have unique custom id for each relation. So I add a global relation index, and g.E().has('KEY',value) does use edge index, as of Titan 1.0.0. Other circumstances not tested.

Titan uses index id and index property value as rowkey, internal relation id as column and external relation id, such as 1g9ocn9jk-1g9ocnaf4-6c5-1g9ocndkw, as value.

X. Wu
  • 1
  • 1