在Cypher查询中返回唯一节点

时间:2018-12-13 14:12:20

标签: neo4j cypher

我有一个查询,该查询可能返回大量行。尽可能快是至关重要的。

我当前的查询显示由于过滤器折线而使节点加倍,我该如何做才能显示n.NAME呢?

PS:PS:如果我删除:-> extract(n in segments | n.ORIGIN_POLYLINE) as polylines,,那么我有很好的结果,但是我想让折线具有唯一的节点(请参见图片:1和2)

这是我的查询:

MATCH (p:Polyline_ROMANIA)-[:CONTAINS_ROMANIA]->(n:Point_ROMANIA) 
WHERE p.ID_POLYLINE='9141'
WITH head(COLLECT(n)) as start
MATCH c=(start)<-[:SEGMENT_ROMANIA*0..]-(pt1:Point_ROMANIA)<-[:CONNECTED_ROMANIA]-(e:Establishment_ROMANIA) 
WITH 2 * 6371 * asin(sqrt(haversin(radians(toFloat(e.Y) - toFloat(start.Y))) + cos(radians(toFloat(e.Y)))* cos(radians(toFloat(start.Y)))* haversin(radians(toFloat(e.X) - toFloat(start.X))))) AS distance, e, c 
WHERE  distance <= 5000
WITH Distinct e, filter(n in rels(c) where n.ORIGIN_POLYLINE IS NOT NULL) AS segments, distance 
RETURN e as nodes, extract(n in segments | n.ORIGIN_POLYLINE) as polylines, distance

image 1

image 2

0 个答案:

没有答案