Question

I am using neo4j 2.0 to store a lot of data. The data massive amount is generated using a ruby script and saved in a graphml file and then imported into neo4j using Gremlin.

g.loadGraphML('graphml.xml')

With neo4j 2.0, there is a new cool support for labels on a node which I would like to take advantage of. Is it possible to specify which labels a node should have in this way? Or do I really have to make queries afterwards for all nodes, setting their labels.

Thanks

Was it helpful?

Solution

I do not believe there is a way, at least within Blueprints, which is the interface which Gremlin is built upon. I don't see a way to add a label for a Vertex, nor do I see anything like that in GraphML.

Perhaps Neo4j will update their code to put the label(s) into a property for a Vertex in blueprints, but currently there is no way to get/set the labels using Gremlin/Tinkerpop.

It should also be noted that Blueprints only supports stable versions of Neo4j as we know, so something like 2.0 which is a Milestone wouldn't be fully supported in Blueprints yet.

OTHER TIPS

If you're using Neo4j version 2 you can set a label by getting the underlying Neo4j Node from the Blueprint Vertex. Note that this breaks the encapsulation and adds a dependence on Neo4j, but this may be required. Also, due to issues with the latest version of Blueprint I'm still not able to use this code properly, but this is how it'd work.

import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph;
import com.tinkerpop.blueprints.impls.neo4j.Neo4jVertex;
import org.neo4j.graphdb.Node;

// ...

Vertex vertex = graph.addVertex(null);
Neo4jVertex neo4jVertex = (Neo4jVertex) vertex;
Node node = neo4jVertex.getRawVertex();
node.addLabel("SomeLabel");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top