【问题标题】:neo4j spatial cypher withinDistance issueneo4j 空间密码 withinDistance 问题
【发布时间】:2013-03-11 00:10:37
【问题描述】:

我无法让 withinDistance 在 Cypher 中正常工作。

我可以毫无问题地使用空间 REST findGeometriesWithinDistance 创建图层、添加几何图形、调用索引和查询。

  1. POST /db/data/ext/SpatialPlugin/graphdb/addEditableLayer {"layer":"yada"}
  2. POST /db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer { "layer":"yada","geometry":"LINESTRING (-87.8269667076541 42.5931258671059,-87.8280193743192 42.5930348004394,-87.8284217076519 42.5931722004391)"}
  3. POST /db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer {"layer":"yada","geometry":"LINESTRING (-87.8118643076776 42.588086600447,-87.8183341743342 42.5876782004477,-87.818426974334 42.5877468671142)"}
  4. POST /db/data/index/node/ {"name":"yada", "config":{"provider":"spatial","wkb":"wkb"}}
  5. POST /db/data/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance {"layer":"yada","distanceInKm":2,"pointX":-87.845556,"pointY":42.582222}

但是,当我使用 Cypher 拨打 withinDistance 时,例如

  • POST /db/data/cypher {"query":"START n=node:yada('withinDistance:[-87.845556,42.582222,10.0]') RETURN n"}

我回来了

400 Bad Request
{
  "message" : "only within, WITHINDISTANCE and bbox are implemented.",
  "exception" : "BadInputException",
  "stacktrace" : [ "org.neo4j.server.rest.repr.RepresentationExceptionHandlingIterable.exceptionOnHasNext(RepresentationExceptionHandlingIterable.java:50)", "org.neo4j.helpers.collection.ExceptionHandlingIterable$1.hasNext(ExceptionHandlingIterable.java:60)", "org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)", "org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:58)", "org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)", "org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)", "org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:57)", "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:42)", "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:179)", "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:131)", "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:117)", "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:55)", "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:75)", "java.lang.reflect.Method.invoke(Method.java:601)" ],
  "cause" : {
    "message" : "only within, WITHINDISTANCE and bbox are implemented.",
    "exception" : "UnsupportedOperationException",
    "stacktrace" : [ "org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.query(LayerNodeIndex.java:277)", "org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.indexQuery(GDSBackedQueryContext.scala:83)", "org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$2.apply(IndexQueryBuilder.scala:83)", "org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$2.apply(IndexQueryBuilder.scala:81)", "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:36)", "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:35)", "scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)", "org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:36)", "org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)", "org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)", "org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:86)", "org.neo4j.cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35)", "org.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:142)", "scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)", "scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:29)", "org.neo4j.helpers.collection.ExceptionHandlingIterable$1.hasNext(ExceptionHandlingIterable.java:58)", "org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)", "org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:58)", "org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)", "org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)", "org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:57)", "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:42)", "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:179)", "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:131)", "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:117)", "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:55)", "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:75)", "java.lang.reflect.Method.invoke(Method.java:601)" ]
  }

我不确定这种行为是什么时候开始的,但它似乎是最近才出现的。我在这里做错了吗?

谢谢, 保罗

  • neo4j 1.9.M05
  • neo4j 空间 0.11
  • jdk1.7.0_17

【问题讨论】:

标签: neo4j


【解决方案1】:

有一个类似的问题,REST 请求可以工作,但 Cypher 没有。解决方案是以标准方式创建另一个“正常”节点索引(即 lucene 索引,而不是空间索引),并将其命名为与您的空间索引相同。

在您的示例中,您创建了一个名为 yada 的空间索引,为了使 Cypher 正常工作,您将执行here 中描述的操作并创建一个标准的 neo4j 节点索引,然后将您的节点添加到其中。

然后您可以通过 Cypher 进行 withinDistance 查询。不过要指出的是,这不会让您执行标准的 Cypher 查询,例如 START n=node:yada('*:*') RETURN n;,它只会让您执行空间查询。

这是在 Windows 上使用 Neo4j 1.9。

【讨论】:

  • 仍然不行,当使用另一个“普通”节点索引和旧索引时,我使用 neo4j 2.2.1
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-31
  • 2013-11-11
  • 2017-05-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多