在其他条件下使用Neo4J Spatial Cypher查询 [英] Using Neo4J Spatial Cypher queries with other conditions

查看:132
本文介绍了在其他条件下使用Neo4J Spatial Cypher查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Neo4J Spatial cypher查询来查找25KM半径内的用户,并在其中找到与我有相同家乡的用户.我使用以下查询:

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;

此查询与我预期的方式不符.它标识给定半径内的所有用户节点,并对每个节点执行相同的MATCH查询,该查询特定于节点ID为5的用户.

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.

将这个问题分为两部分,这就是我想结合的部分. 第一部分,确定25公里半径内的所有用户:

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?

推荐答案

那么,如果我正确理解节点"包含给定半径内的所有家乡,该怎么办?在哪种情况下,您将要做什么?

So if I understand correctly 'node' contains all the home towns in a given radius? In which case would the following do what you want?

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

我看到Peter在邮件列表中回答了.所以实际上我的假设是错误的,节点"代表用户,这就是答案:

I see Peter has answered on the mailing list. So actually my assumption was wrong, 'node' represents users which means this is the answer:

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

这篇关于在其他条件下使用Neo4J Spatial Cypher查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆