空间密码查询不起作用 [英] Spatial cypher queries don't work

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

问题描述

我通过以下REST API调用为Neo4j配置了空间插件:

I configured the spatial plugin for Neo4j with the following REST API Calls:

POST http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer
{
 "layer" : "geom",
 "lat" : "lat",
 "lon" : "lon"
}

POST http://localhost:7474/db/data/index/node/
{
  "name" : "geom",
  "config" : {
    "provider" : "spatial",
    "geometry_type" : "point",
    "lat" : "lat",
    "lon" : "lon"
  }
}

我添加具有以下Scala代码(嵌入到Play应用程序中)的空间节点:

I add spatial nodes with the following Scala code (embedded in a Play application):

val mergeStatement = Cypher(
  """
    MERGE (location: Location {placesID: {id}, name: {name}, lat: {lat}, lon: {lon}})
    RETURN id(location)
  """
).on("id" -> id, "name" -> name, "reference" -> reference, "lat" -> latitude, "lon" -> longitude)
val nodeID = mergeStatement().head[Long]("id(location)")

val bodyA = JsObject(Seq(("value",JsString("dummy")),("key",JsString("dummy")),("uri", JsString(Neo4jREST.baseURL + "node/" + nodeID.toString))))

WS.url(Neo4jREST.baseURL + "index/node/geom").withHeaders("Accept" -> "application.json").post(bodyA) map { response =>

    val bodyB = JsObject(Seq(("layer",JsString("geom")),("node", JsString(Neo4jREST.baseURL + "node/" + nodeID.toString))))

    WS.url(Neo4jREST.baseURL + "ext/SpatialPlugin/graphdb/addNodeToLayer").withHeaders("Accept" -> "application.json").post(bodyB)
}

一切都很好,并且

POST http://neo4jurl/db/data/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance`
{
  "layer" : "geom",
  "pointX" : 8.5,
  "pointY" : 47.3,
  "distanceInKm" : 10
}

返回一些Location节点(以及一些来自空间索引本身的节点-这是正常的吗?),但是

returns some Location nodes (and some nodes from the spatial index itself - is this normal?) but

POST http://neo4jurl//db/data/cypher
{
 "query" : "start node = node:geom('withinDistance:[8.5,47.3, 10.0]') return node"
}

仅返回

{
  "columns" : [
    "node"
  ],
  "data" : []
} 

怎么了?缺少什么了吗?

What is wrong? Is something missing?

推荐答案

您正在混合使用索引的图层.密码查询仅适用于索引.因此,甚至不要创建图层.只需创建一个空间索引,然后向该空间索引中添加节点,然后cypher就会看到它们.

You are mixing up Layers with Indexes. The cypher query only works off indexes. So don't even create a layer. Just create a spatial index, and add nodes to the spatial index, then cypher will see them.

请参见 http://maxdemarzi.com/2014/01/例如31/neo4j-spatial-part-1/.

这篇关于空间密码查询不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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