我按照教程http://neo4j.github.io/spatial/#rest-api-add-a-node-to-the-spatial-index來測試Spatial 0.12與Neo4j 2.0M03。我正在嘗試SimplePointLayer示例,以獲取半徑內的節點。Neo4j 2.0M3空間0.12 - 空間不會爲我的查詢返回任何結果
雖然它看起來像所有東西都被創建(層,索引等),並且我的域節點索引正確,我的Cypher查詢或我的Java空間查詢代碼不會返回任何結果。
當我嘗試Neo4j 1.9和Spatial 0.11完全相同的東西時,它工作得很好。
在深入研究這個問題之前,如果這是一個已知問題,我想問問Neo4j社區。提前致謝。
{
"layer" : "geom",
"lat" : "lat",
"lon" : "lon"
}
curl -H "Content-Type: application/json" -X POST -d @geo_layer.json http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer
geo_index.json:
{
"name" : "geom",
"config" : {
"provider" : "spatial",
"geometry_type" : "point",
"lat" : "lat",
"lon":"lon"
}
}
curl -H "Content-Type: application/json" -X POST -d @geo_index.json http://localhost:7474/db/data/index/node
geo_node.json:
{
"lat" : 60.1,
"lon" : 15.2
}
curl -H "Content-Type: application/json" -X POST -d @geo_node.json http://localhost:7474/db/data/node
-
geo_layer.json - 基於彼得的評論測試步驟
新節點的ID是 - 我從一個空的圖開始。
domain_node.json:
{
"value": "dummy",
"key": "dummy",
"uri": "http://localhost:7474/db/data/node/5"
}
curl -H "Content-Type: application/json" -X POST -d @domain_node.json http://localhost:7474/db/data/index/node/geom
cypher_query.json:
{
"query": "start node = node:geom('withinDistance:[60.0,15.0, 100.0]') return node;"
}
curl -H "Content-Type: application/json" -X POST -d @cypher_query.json http://localhost:7474/db/data/cypher
其結果是:
{
"message" : "org.neo4j.gis.spatial.indexprovider.GeoPipeFlowHits.iterator()Lorg/neo4j/graphdb/ResourceIterator;",
"exception" : "AbstractMethodError",
"fullname" : "java.lang.AbstractMethodError",
"stacktrace" : [ "org.neo4j.cypher.internal.spi.gdsimpl.TransactionBoundQueryContext$NodeOperations.indexQuery(TransactionBoundQueryContext.scala:120)", "org.neo4j.cypher.internal.spi.DelegatingOperations.indexQuery(DelegatingQueryContext.scala:107)", "org.neo4j.cypher.internal.executionplan.builders.EntityProducerFactory$$anonfun$2$$anonfun$applyOrElse$2.apply(EntityProducerFactory.scala:70)", "org.neo4j.cypher.internal.executionplan.builders.EntityProducerFactory$$anonfun$2$$anonfun$applyOrElse$2.apply(EntityProducerFactory.scala:68)", "org.neo4j.cypher.internal.executionplan.builders.EntityProducerFactory$$anon$1.apply(EntityProducerFactory.scala:38)", "org.neo4j.cypher.internal.executionplan.builders.EntityProducerFactory$$anon$1.apply(EntityProducerFactory.scala:37)", "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:34)", "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:33)", "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:84)", "org.neo4j.cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35)", "org.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:157)", "scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)", "scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:29)", "org.neo4j.cypher.PipeExecutionResult$$anon$1.hasNext(PipeExecutionResult.scala:73)", "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:83)", "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:42)", "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:185)", "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:133)", "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:119)", "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:57)", "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:96)", "java.lang.reflect.Method.invoke(Method.java:601)", "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)" ]
- 可選地 -
location.json:
{
"layer" : "geom",
"node" : "http://localhost:7474/db/data/node/5"
}
curl -H "Content-Type: application/json" -X POST -d @location.json http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer
geo_query.json:
{
"layer" : "geom",
"distanceInKm" : "100",
"pointX" : "15",
"pointY" : "60"
}
curl -H "Content-Type: application/json" -X POST -d @geo_query.json http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/findGeometriesWithinDistance
返回結果爲空。
感謝您的答覆彼得。我列出了一個模擬您建議我查看的單元測試的新測試結果。不知道我得到的錯誤意味着什麼。我從github克隆了最新的Spatial代碼並用於此測試。我的Neo4j版本是2.0M3,我從網站上下載 - 我還沒有建立自己的自我。我不知道這是否意味着什麼,但是當我按照上述步驟操作時,我看到兩個索引創建爲結果。第一個是「geom__neo4j-spatial__LayerNodeIndex__internal__spatialNodeLookup__」,第二個是「geom」。任何想法? – BmRb
最後一個註釋。當我在1.9.1上進行同樣的測試時,它就像一個魅力。 – BmRb