Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

After creating index using the Web Console Index Manager, still cannot access index in Gremlin #138

Closed
lassewesth opened this Issue · 7 comments

2 participants

@lassewesth
Owner

@ceefour: '1. Go to Web Console - Index Manager > create an index
2. Go to Web Console - Gremlin shell, type :

    g.idx('satukancinta_person')

It returns null.

Restarting neo4j server makes the index accessible.'

@lassewesth
Owner

values:

@lassewesth
Owner

@jexp: Gremlin probably loads the indexes on start? What happens if you create the index via gremlin?

@lassewesth
Owner

@ceefour: See http://stackoverflow.com/questions/8956159/why-does-gremlin-idx-returns-with-null-although-the-db-is-not-empty

I use a Gremlin/Groovy snippet found in the Neo4j docs

neo4j = g.getRawGraph()
idxManager = neo4j.index()
personIndex = idxManager.forNodes('vertices')

To get to the index before an index change is "visible" to Gremlin, try this:

import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jIndex;
ind = new Neo4jIndex('vertices', Vertex.class, g)

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').

@lassewesth
Owner

@jexp: What about this?

g.createAutomaticIndex('test',Vertex.class, ['name'] as Set) 

From: http://groups.google.com/group/neo4j/browse_thread/thread/a9ed2e526919cf1f

@lassewesth
Owner

@ceefour: Thanks Michael! Based on your clue, I managed to find the "true way" of creating Neo4j indexes using Gremlin in the web console :

gremlin> g.createManualIndex('test2', Vertex.class)
==> MANUAL[test2:Vertex]
gremlin> test2=g.idx('test2')
==> MANUAL[test2:Vertex]
gremlin> hendy=g.v(1673)
==> v[1673]
gremlin> hendy.name
==> Hendy Irawan
gremlin> test2.put('name', 'Hendy Irawan', hendy)
==>
gremlin> test2.get('name', 'Hendy Irawan')
==> v[1673]

Note: g.createAutomaticIndex() won't do what most people would expect here, it will create a Neo4j manual index that is automatically updated by Blueprints to index ALL NODES (i.e. Vertex class) with a name property.

Please consider this issue fixed/invalid. However, this should be documented somewhere, and with a reference to https://github.com/tinkerpop/blueprints/wiki/Graph-Indices .....

@lassewesth
Owner

@peterneubauer: Thanks Hendy, will flag it as an enhancement.

@nawroth nawroth referenced this issue in neo4j-contrib/gremlin-plugin
Open

Document index behavior for web console vs gremlin #4

@nawroth
Owner

Opened an issue for the gremlin plugin instead: neo4j-contrib/gremlin-plugin#4

@nawroth nawroth closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.