2013-10-16 70 views
1

讓我們說我有兩個節點用一個邊緣爲:如何在邊緣屬性上創建查找索引?

country ---> has ---> school 

其中,邊緣「也」呼籲財產「因爲」。

如果我爲節點和邊+邊屬性創建了查找索引。

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

如何在edge屬性(since)上創建索引。或在邊緣「has」中創建索引時。屬性得到索引。是嗎 ?

Neo4j.property我設置爲:

# 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 

,但我不希望通過此屬性文件來創建自動索引,但增加的頂點/邊之前需要小鬼方式。

像泰坦方式:

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

怎能有可能通過簡單的Neo4j +小鬼?

上午以下:

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

回答

1

你混淆了指數的位的概念。在這種方式上Graph使用createKeyIndex

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

也沒有創造一個「索引」邊標籤所謂的「有」。它在名爲「has」的屬性上創建索引,該索引將查找Edge。如果你想「因爲」在一個索引,然後簡單地做:

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

這就是說,沒有什麼,我知道在Neo4j的是類似於頂點泰坦中心指數存在,所以它並不是說你的創作關鍵指數「since」將允許Gremlin在遍歷簡單密鑰索引查找之外利用該索引,如:

g.E('since', new Date()) 
相關問題