I am opening a graph using:
g = new Neo4jGraph('...path...');
then adding a vertex using:
myVertex = g.addVertex(['type':'X', 'Y':Z]);
I can see the db afterwards has a single vertex (using Gephi)
but when I run:
if (g.idx(T.v) != null )
it always returns false.
Should the indexing be turned on somehow?
Does Gremlin require a specific Neo4j version?
Adding some log info:
...
==>v[22092]
==>v[22093]
==>v[22094]
==>v[22095]
gremlin> g.idx(T.v)
==>null
gremlin> g.idx("vertices")
==>null
gremlin> g.indices
gremlin>
Tried this on Gremlin 1.3 – same results. So I guess it is something I am missing.
I think creating indices in Neo4j with Gremlin might be broken. Evidence includes issues raised against neo4j, blueprints and the REST plugin. Even if that’s not the case, Gremlin doesn’t really have first-class access to indices in Neo4j- eg, it can’t create full-text indices last time I checked. Not sure if it can even create relationship indices in Neo.
I use a Gremlin/Groovy snippet found in the Neo4j docs
I realize this breaks the nice abstraction layer that is Gremlin, but afterwards you can go about your day using Gremlin methods like
g.idx('vertices').EDIT:
To get to the index before an index change is “visible” to Gremlin, try this:
The advantage this has over the gist I linked in the comments is that
indis a Gremlin index, and can half the usual Gremlin treatment applied. OTOH, the gist in the comments has full access to the raw index.