1

假设我有两个节点,一条边为:

 country ---> has ---> school

其中,边缘“has”具有名为“ since ”的属性。

如果我为节点和边 + 边属性创建了查找索引。

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

如何在边缘属性上创建索引(因为)。或者在边缘“有”中创建索引时。属性被索引。是吗 ?

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

但我不想通过这个属性文件创建自动索引,但在添加顶点/边之前需要以 gremlin 方式。

就像泰坦的方式:

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

怎么可能通过简单的 neo4j + gremlin 呢?

我正在关注:

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

4

1 回答 1

1

您有点混淆索引的概念。以这种方式createKeyIndex使用:Graph

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

没有创建一个名为“has”的“索引”边缘标签。它正在一个名为“has”的属性上创建一个索引,该索引将查找一个Edge. 如果你想要一个关于“since”的索引,那么只需执行以下操作:

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

也就是说,我所知道的 Neo4j 中没有任何东西类似于 Titan 中的以顶点为中心的索引,所以这并不是说您在“因为”上创建一个关键索引将允许 Gremlin 在遍历中利用该索引在简单的键索引查找之外,例如:

g.E('since', new Date())
于 2013-10-16T11:38:37.940 回答