Frage

let's say I have two nodes with one edge as :

 country ---> has ---> school

where, edge "has" has property called "since".

If I created lookup index for nodes and edges + edge property.

g.createKeyIndex('country', Vertex.class)
g.createKeyIndex('school', Vertex.class)
g.createKeyIndex('has', Edge.class)

How to create index on edge property(since).Or while creating index in edge "has". properties get indexed. Is it ?

in Neo4j.property I set as :

# Autoindexing

# Enable auto-indexing for nodes, default is false
node_auto_indexing=true

# The node property keys to be auto-indexed, if enabled
node_keys_indexable=country, school

# Enable auto-indexing for relationships, default is false
relationship_auto_indexing=true

# The relationship property keys to be auto-indexed, if enabled
relationship_keys_indexable=since

but I don't want to create auto index through this property file but need in gremlin way before adding vertex/edges.

like in Titan way :

g.makeType().name('since').dataType(Date.class).unique(OUT).makePropertyKey()

how can it possible through simple neo4j + gremlin ?

am following :

http://www.tinkerpop.com/docs/javadocs/blueprints/2.1.0/com/tinkerpop/blueprints/KeyIndexableGraph.html#createKeyIndex(java.lang.String, java.lang.Class)

War es hilfreich?

Lösung

You are confusing the concept of indices a bit. Using createKeyIndex on Graph in this way:

g.createKeyIndex('has', Edge.class)

Is not creating an "indexed" edge label called "has". It is creating a index on a property called "has" that will lookup an Edge. If you want an index on "since" then simply do:

g.createKeyIndex('since', Edge.class)

That said, there is nothing I know of that exists in Neo4j that is analogous to vertex centric indices in Titan, so it's not as though your creation of a key index on "since" will allow Gremlin to take advantage of that index in a traversal outside of a simple key index lookup, like:

g.E('since', new Date())
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top