2

我们最近从 Neo4j 1.9 升级到 2.1,现在在使用空间索引更新现有对象时收到错误消息。

我们正在使用以下内容:

Spring Data NEO4J 3.1 Neo4j 2.1.2 服务器与空间插件

我已将问题缩小到以下 REST 调用:

http://localhost:7474/db/data/index/node/<index name>

JSON Post:
{
    "value" : "POINT(-87.626451 41.870515)",
    "uri" : "http://localhost:7474/db/data/node/113",
    "key" : "wkt"
}

我收到以下回复:

{
  "message" : "GeometryNode not indexed in this RTree: 114",
  "exception" : "RuntimeException",
  "fullname" : "java.lang.RuntimeException",
  "stacktrace" : [ "org.neo4j.gis.spatial.rtree.RTreeIndex.findLeafContainingGeometryNode(RTreeIndex.java:812)", "org.neo4j.gis.spatial.rtree.RTreeIndex.remove(RTreeIndex.java:111)", "org.neo4j.gis.spatial.rtree.RTreeIndex.remove(RTreeIndex.java:100)", "org.neo4j.gis.spatial.EditableLayerImpl.update(EditableLayerImpl.java:56)", "org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.add(LayerNodeIndex.java:143)", "org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.add(LayerNodeIndex.java:41)", "org.neo4j.server.rest.web.DatabaseActions.addToNodeIndex(DatabaseActions.java:686)", "org.neo4j.server.rest.web.RestfulGraphDatabase.addToNodeIndex(RestfulGraphDatabase.java:1022)", "java.lang.reflect.Method.invoke(Unknown Source)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "java.lang.Thread.run(Unknown Source)" ]
}

编辑

在做了一些额外的研究后,我发现错误被抛出,因为几何关系的根节点(952)不等于索引根的根节点(2308)。

以下是关联几何节点和索引根的关系和节点属性:

114<-[RTREE_REFERENCE]-6<-[RTREE_CHILD]-952<-[RTREE_CHILD]-(null)

114
id  113
bbox [-87.626451,41.870515,-87.626451,41.870515]
wkt POINT (-87.626451 41.870515)
gtype   1

6
bbox [-88.459688,41.711991,-86.856991,42.153793]

952
bbox [-118.823745,0,0,44.591593]


2307-[RTREE_ROOT]->[2308]

2307
layer_class   org.neo4j.gis.spatial.EditableLayerImpl
layer         dib_location
geomencoder   org.neo4j.gis.spatial.WKTGeometryEncoder
geomencoder_config   wkt
ctime  1404877913340

2308
layer_class org.neo4j.gis.spatial.EditableLayerImpl
layer   dib_location
geomencoder org.neo4j.gis.spatial.WKTGeometryEncoder
geomencoder_config  wkt
ctime   1404877913340
4

2 回答 2

1

我没有使用过旧版本的 Neo4j Spatial,但在当前版本(Neo4j 2.1.2 为 0.13)中,将节点添加到空间索引的命令被描述为

POST http://localhost:7474/db/data/index/node/<index name> {"key":"dummy", "value":"dummy", "uri":"http://localhost:7474/db/data/node/113"}

已经在节点本身上设置了 wkt 属性。如果您查看 LayerNodeIndex.java 源文件,您将看到键和值参数被忽略。因此,使用 Cypher 或 REST 将 wkt 属性添加到节点,然后将节点添加到空间索引,它应该可以正常用于 Cypher 查询。

如果您想做 REST 查询,您会发现将节点添加到您正在使用的空间索引的方法不会将节点添加到 RTree 图。它创建一个新节点,将原始节点的几何属性或属性放在新节点上,将原始节点的节点号放入用户“id”属性中,并将此新节点放入 RTree 图中。因此,当您执行 REST 空间查询时,您会返回这个“复制”节点。要获取原始节点,您必须使用复制节点的“id”属性中存储的值通过节点编号获取节点。如果您不使用 Cypher,请使用 REST addNodeToLayer。如果您想在不涉及复制节点的情况下同时执行这两项操作,请创建一个自引用用户“id” 在使用 addNodeToLayer 调用将其添加到层之前,包含其 Neo4j 节点号的原始节点上的属性。如果这样做,则根本不需要使用 REST add to index 调用,所有方法都可以使用。

顺便说一句,Neo4j 空间索引(路径 /db/data/index/node/ 访问的那个)实际上并没有任何内容。它是空间插件的接入点存根。

为了回答您评论中的进一步问题,请查看我对其他问题的回答,以查看要进行的 REST 调用的详细示例。

于 2014-07-14T20:49:45.027 回答
0

在 Neo4j 2.x 中,我们不得不改变工作方式,因为不再有默认的根节点。您应该能够将根节点(节点 0))标记为:ReferenceNode. 然后它应该再次工作。

于 2014-07-10T17:07:58.377 回答