距离内的 Neo4j 空间密码查询不返回现有节点 [英] Neo4j spatial cypher query withinDistance doesn't return existing nodes

查看:21
本文介绍了距离内的 Neo4j 空间密码查询不返回现有节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Neo4j 2.0 的空间服务器插件并遵循 http://neo4j.github 上的指南.io/spatial/ 添加一个名为 Stockholm 的节点.

I am using the spatial server plugin for Neo4j 2.0 and have followed the guide at http://neo4j.github.io/spatial/ to add a node with name Stockholm.

:POST http://localhost:7475/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer
{
  "layer" : "geom",
  "lat" : "lat",
  "lon" : "lon"
}
:POST http://localhost:7475/db/data/index/node/
{
  "name" : "geom",
  "config" : {
    "provider" : "spatial",
    "geometry_type" : "point",
    "lat" : "lat",
    "lon" : "lon"
  }
}
:POST http://localhost:7475/db/data/node
{
  "lat" : 60.1,
  "lon" : 15.2,
  "name" : "Stockholm"
}
:POST http://localhost:7475/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer
{
  "layer" : "geom",
  "node" : "http://localhost:7475/db/data/node/4"
}

我可以通过 REST 检索节点:

I am able to retrieve the node via REST with:

:POST http://localhost:7475/db/data/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance
{
  "layer" : "geom",
  "pointX" : 15.0,
  "pointY" : 60.0,
  "distanceInKm" : 100
}

但不是下面的密码查询.这是为什么?我在这里犯了什么明显的错误吗?

but not with the cypher query below. Why is that? Am I doing any obvious mistake here?

START n=node:geom('withinDistance:[60.0,15.0, 100.0]') RETURN n;

推荐答案

为了使用 Cypher 进行查询,您需要将每个节点添加到索引中:

In order to query using Cypher you'll need to add each node to an index:

    :POST http://localhost:7474/db/data/index/node/geom
    {
      'value': 'dummy', 
      'key': 'dummy', 
      'uri': 'http://localhost:7474/db/data/node/NODE_ID_HERE'
    }

我最近写了一篇关于开始使用 Neo4j Spatial 的博客文章,内容包括:http://lyonwj.com/mapping-the-worlds-airports-with-neo4j-spatial-and-openflights-part-1/

I wrote a blog post about getting starting with Neo4j Spatial recently that covers this: http://lyonwj.com/mapping-the-worlds-airports-with-neo4j-spatial-and-openflights-part-1/

这篇关于距离内的 Neo4j 空间密码查询不返回现有节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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