Using new KeySpaces in Titan Cassandra and persistent data

I just started using Titan over Cassandra. I am new to Titan and also new to Graph database concept. Just follow the instructions on github and wiki.

Configuration conf = new BaseConfiguration(); conf.setProperty("storage.backend", "cassandra"); conf.setProperty("storage.hostname", "127.0.0.1"); TitanGraph g = TitanFactory.open(conf); 

This is how I opened the chart.

I understand that the default titan is titan . I created some nodes and relationships in the default key space. I did indexing on the top and requested nodes and was able to iterate the results.

Now my questions are

1) How to set a new keyspace?

I tried to use the property

 conf.setProperty("storage.keyspace ", "newkeyspace"); 

Unfortunately, when I checked the cassandra key areas, I could only find titan . There was no key space named newkeyspace . What could be the reason?

2) How to save the schedule?

eg,

 g.createKeyIndex("name", Vertex.class); Vertex juno = g.addVertex(null); juno.setProperty("name", "juno"); juno.setProperty("type", "node"); Vertex juno1 = g.addVertex(null); juno1.setProperty("name", "juno"); juno1.setProperty("type", "node1"); 

This is one sample graph. As soon as I issue a form request

 Iterator<Vertex> junoIterator = g.getVertices("name", "juno") .iterator(); while (junoIterator.hasNext()) { Vertex vertex = (Vertex) junoIterator.next(); System.out.println(vertex.getProperty("type")); } 

Expected Result

 node node1 

The same query should work fine as soon as I comment on the next segment -

  /*g.createKeyIndex("name", Vertex.class); Vertex juno = g.addVertex(null); juno.setProperty("name", "juno"); juno.setProperty("type", "node"); Vertex juno1 = g.addVertex(null); juno1.setProperty("name", "juno"); juno1.setProperty("type", "node1");*/ 

Here, I believe that the nodes, relationships, and index are already created and stored in some kind of data warehouse. Am I mistaken?

I ask for advice.

+4
source share
2 answers

I figured out this problem. This is just a matter of commission.

The only line is g.commit(); solves everything.

+3
source

To create a new Titan table (Keyspace in cassandra), use this property:

set ("storage.cassandra.keyspace", "TitanTest")

the whole wud command will look like this:

graph = TitanFactory.build (). set ("storage.backend", "Cassandra"). set ("storage.hostname", "127.0.0.1"). set ("index.search.backend", "elasticsearch"). set ("storage.cassandra.astyanax.cluster-name", "Test Cluster"). set ("storage.cassandra.keyspace", "TitanTest") set ("cache.db cache", "true") is open (); ..

0
source

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


All Articles