Create an index for a vertex property that already exists in Titan (Cassandra)?

I am using Titan Server (Cassandra) v 0.3.1. I would like to create an index for the vertex key / property that I have already started using. However, in its documentation, Titan explains that:

To index vertices by key, you must create the corresponding key index before the key is first used in the vertices property.

If I try to create an index in an existing field, I see an error as expected:

gremlin> g.createKeyIndex("my_key",Vertex.class) Cannot add an index to an already existing property key: my_key 

However, even if I try to clear the graph by deleting all the vertices and edges, I see the same error:

 gremlin> gEremove() ==>null gremlin> gVremove() ==>null gremlin> g.createKeyIndex("my_key",Vertex.class) Cannot add an index to an already existing property key: my_key 

Thus, it seems that my_key stored in the underlying data store even after deleting all the graph elements. This is consistent with the documents (although the elements were deleted, the property was already β€œfirst used”), but it seemed to be worth taking a picture.

The next step will be to re-create the new Cassandra data warehouse, but I wonder if there is a better option.

What is the easiest way to create an index on a field that has already been used in Titan?

+6
source share
2 answers

Point Titan to the new Cassandra data warehouse and create an index before inserting any elements with this property.

 gremlin> g.createKeyIndex("my_key",Vertex.class) ==>null 
+3
source

Try this gremlin query:

 gremlin> gVeach{g.removeVertex(it)} 

You do not need to manually delete faces, because if a vertex is deleted, all edges associated with it will be deleted automatically. And to remove all vertices, you need to use an iterative query.

Once the schedule is cleared, you will not need a new KeySpace. Then you can use:

 gremlin> g.createKeyIndex("my_key",Vertex.class) 
+3
source

Source: https://habr.com/ru/post/947369/


All Articles