在 Neo4J 3.x 中自动填充关系索引?

Automatically populate relationship index in Neo4J 3.x?

在 Neo4J 2.x 中,conf 设置中有一个特殊选项可以自动索引某些关系属性。

但是3.x怎么办呢?它可以自动填充关系索引吗?哪个 APOC 函数可以用于此?我在手册里找不到...

您可以使用 triggers。例如创建关系的触发器:

CALL apoc.trigger.add(
 'relsIndexUpdateCreatedRelationships',
 'UNWIND {createdRelationships} as rel
  CALL apoc.index.addRelationship(rel, ["user"])
  RETURN count(rel)
 ',
 {phase: 'after'}
)

当然,您还需要处理这些触发器:deletedRelationshipsremovedRelationshipPropertiesassignedRelationshipProperties