如何在Neo4J本机全文索引中获取关系的起点和终点?

时间:2020-04-23 12:51:26

标签: neo4j cypher neo4j-apoc

在Neo4J 3.5中,我在某种类型的关系(:IN)上设置了本机索引,并使用它来查询它们,效果很好:

CALL db.index.fulltext.queryRelationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD relationship RETURN DISTINCT relationship;

但是,在APOC中,我也可以使用以下查询来查询关系的开始和结束节点:

CALL apoc.index.relationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD start,end RETURN DISTINCT start, end;

这非常有帮助。

当我尝试做

CALL db.index.fulltext.queryRelationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD start, end RETURN DISTINCT start, end;

它不起作用。

那么,如果我想检索的不是实际关系,而是检索它们所链接的节点,该怎么办?

2 个答案:

答案 0 :(得分:0)

[编辑]

这应该有效:

CALL db.index.fulltext.queryRelationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD relationship
RETURN DISTINCT STARTNODE(relationship) AS start, ENDNODE(relationship) AS end;

答案 1 :(得分:0)

这可以连接节点

CALL db.index.fulltext.queryRelationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD relationship, score
match (node)-[relationship]-(b)
RETURN node, b