2

在论坛中问过同样的问题Spring Data,但认为它与Neo4j API. 中运行时查询工作正常webadmin。请求/响应,如下所示。更新: - 当值被硬编码和传递时工作正常。

POST /db/data/cypher HTTP/1.1
Accept: application/json;stream=true
X-Stream: true
Content-Type: application/json
User-Agent: neo4j-rest-graphdb/0
Host: localhost:7000
Connection: keep-alive
Transfer-Encoding: chunked

b1
{"query":"START n=node:LAT_LONG('withinDistance:[{0},{1}, {2}]') match  n<-[:address]-(location)<-[:CONTAINS]-(pol)  return pol","params": {"2":50.0,"1":-74.598347,"0":39.274423}}
0

收到的异常是:

HTTP/1.1 400 Bad Request
Content-Encoding: UTF-8
Content-Type: application/json; stream=true
Transfer-Encoding: chunked
Server: Jetty(6.1.25)
D70
{"exception":"BadInputException","fullname":"org.neo4j.server.rest.repr.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$1.write(OutputFormat.java:144)"],"cause":{"exception":"NullPointerException","fullname":"java.lang.NullPointerException","stacktrace":["org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.query(LayerNodeIndex.java:246)","org.neo4j.gis.spatial.indexprovider.LayerNodeIndex.query(LayerNodeIndex.java:289)","org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.indexQuery(GDSBackedQueryContext.scala:87)","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.matching.MonoDirectionalTraversalMatcher.findMatchingPaths(MonodirectionalTraversalMatcher.scala:45)","org.neo4j.cypher.internal.pipes.TraversalMatchPipe$$anonfun$internalCreateResults$1.apply(TraversalMatchPipe.scala:38)","org.neo4j.cypher.internal.pipes.TraversalMatchPipe$$anonfun$internalCreateResults$1.apply(TraversalMatchPipe.scala:35)","scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)","scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)","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:133)","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$1.write(OutputFormat.java:144)"]}}
0

Spring我在论坛中的问题的链接是BadInputException-for-a-neo4j-Custom-query

4

1 回答 1

3

您不能在索引查询的字符串中使用参数'withinDistance:[{0},{1}, {2}]',您必须提供整个索引查询作为参数。

{"query":"START n=node:LAT_LONG({indexQuery}) 
          match n<-[:address]-(location)<-[:CONTAINS]-(pol) 
          return pol",
 "params": {"indexQuery": "withinDistance:[39.27442339.274423, -74.598347, 50.0 ]"} }
于 2013-07-10T19:57:44.530 回答