Indexing Neo4j APOC触发器和关系属性的手动索引
我想设置Neo4j APOC触发器,将所有关系属性添加到手动索引中,如下所示:Indexing Neo4j APOC触发器和关系属性的手动索引,indexing,neo4j,cypher,neo4j-apoc,Indexing,Neo4j,Cypher,Neo4j Apoc,我想设置Neo4j APOC触发器,将所有关系属性添加到手动索引中,如下所示: CALL apoc.trigger.add('HAS_VALUE_ON_INDEX',"UNWIND {createdRelationships} AS r MATCH (Decision)-[r:HAS_VALUE_ON]->(Characteristic) CALL apoc.index.addRelationship(r,['property_1','property_2']) RETURN count(
CALL apoc.trigger.add('HAS_VALUE_ON_INDEX',"UNWIND {createdRelationships} AS r MATCH (Decision)-[r:HAS_VALUE_ON]->(Characteristic) CALL apoc.index.addRelationship(r,['property_1','property_2']) RETURN count(*)", {phase:'after'})
问题是我不知道关系属性的确切值集,因为我对Spring数据Neo4 5使用动态属性方法
是否可以更改此触发器声明,以便能够将
关系属性(现有的和将来将创建的)上的所有HAS\u VALUE\u添加到手动索引,而不是预配置的属性(如所述示例中的['property\u 1','property\u 2']
)?如果您事先不知道属性集,则可以使用函数将创建的关系的所有属性添加到索引中:
CALL apoc.trigger.add(
'HAS_VALUE_ON_INDEX',
'UNWIND {createdRelationships} AS r MATCH (Decision)-[r:HAS_VALUE_ON]->(Characteristic)
CALL apoc.index.addRelationship(r, keys(r)) RETURN count(*)',
{phase:'after'}
)