2013-03-11 53 views
0

我無法讓withinDistance在Cypher中正常工作。neo4j空間密碼內的距離問題

我能夠創建一個圖層,添加幾何圖形,使用空間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
+0

是否將字母從'withinDistance'改爲'WITHINDISTANCE'使它更好? – ulkas 2013-03-11 08:08:08

+0

不,我認爲這是源代碼中的錯字(https://github.com/neo4j/spatial/blob/master/src/main/java/org/neo4j/gis/spatial/indexprovider/LayerNodeIndex.java),行278表示「只有%s,%s和%s得到實施。」 – pauldzy 2013-03-11 09:25:05

回答

0

也有類似的問題,其中的REST請求的工作,但Cypher支架沒有。解決方法是以標準方式創建另一個「正常」節點索引(即lucene索引,而不是空間索引),並將其命名爲空間索引。

在您的例子,你創建一個名爲yada空間索引,使暗號工作,那麼,你會怎樣描述here做出了標準的Neo4j節點索引,然後添加您的節點了。

然後,您可以通過Cypher執行withinDistance查詢。指向不,但這不會讓你做像標準Cypher查詢START n=node:yada('*:*') RETURN n;它只會讓你做空間查詢。

這是在Windows上使用Neo4j 1.9。

+0

仍然不起作用,當使用具有傳統索引的另一個「正常」節點索引時,我使用neo4j 2.2.1 – navins 2015-05-29 06:25:51