2

I am using Neo4J Spatial cypher queries to find users in a 25KM radius, and among them find those who have the same hometown as I do. I used the following query:

START u=node(5),node=node:geom('withinDistance:[17.3,78.3,25.0]') MATCH (u)-[:hometown]->()<-[:hometown]-(o) RETURN o;

This query doesn't work the way I intended. It identifies all user nodes in the given radius and executes the same MATCH query, which is specific to user with node ID 5, for each of those nodes.

Splitting this problem into two parts, this is what I would like to combine. First part, identify all users in a 25 KM radius:

START node=node:geom('withinDistance:[17.3,78.3,25.0]') RETURN node;    

Second part, identify all users who have the same hometown as I do:

START u=node(5) MATCH (u)-[:hometown]->()<-[:hometown]-(o) RETURN o;

How do I combine these two queries into a single query?

4

1 回答 1

2

因此,如果我理解正确,“节点”包含给定半径内的所有家乡?在哪种情况下,以下会做你想要的?

START u=node(5),town=node:geom('withinDistance:[17.3,78.3,25.0]') 
MATCH town<-[:hometown]-o

WITH u, o
MATCH (u)-[:hometown]->()<-[:hometown]-(o) 
RETURN o

我看到彼得已经在邮件列表上回答了。所以实际上我的假设是错误的,“节点”代表用户,这就是答案:

START u=node(5),o=node:geom('withinDistance:[17.3,78.3,25.0]') 
MATCH (u)-[:hometown]->()<-[:hometown]-(o) 
RETURN o
于 2013-08-11T13:42:04.823 回答