您可以在通过REST API传递的多索引查找密码查询中使用参数吗?

时间:2013-08-20 14:48:06

标签: neo4j

我想执行类似于:

的Cypher查询
START n=node:myindex('value:"hello" OR value:"world"') return n

使用REST API,这样的工作:

POST http://localhost:7474/db/data/cypher {"query" : "start n = node:myindex('value=hello OR value=world') return n"}

(从现在开始,我将剥离POST <url>位并超越JSON)

我想做的是参数化查询,理想情况是:

{
 "query" : "start n = node:myindex('value={p0} OR value={p1}') return n", 
 "params" : { "p0" : "hello", "p1" : "world"}
}

但这给了我:

400 Bad Request
{
  "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.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:95)", "java.lang.reflect.Method.invoke(Unknown Source)" ],
  "cause" : {
    "exception" : "NullPointerException",
    "stacktrace" : [ "org.apache.lucene.util.SimpleStringInterner.intern(SimpleStringInterner.java:54)", "org.apache.lucene.util.StringHelper.intern(StringHelper.java:39)", "org.apache.lucene.index.Term.<init>(Term.java:38)", "org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:643)", "org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1436)", "org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1319)", "org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1245)", "org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1234)", "org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)", "org.neo4j.index.impl.lucene.IndexType.query(IndexType.java:300)", "org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:227)", "org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:238)", "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.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: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.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:95)", "java.lang.reflect.Method.invoke(Unknown Source)" ],
    "fullname" : "java.lang.NullPointerException"
  }
}

有没有实现这个目标?

修改

如果我传入,请参考:

{
 "query" : "start n = node:myindex('value=hello OR value=world') return n"
}

我得到了结果,我假设问题在于索引查询周围的'

1 个答案:

答案 0 :(得分:2)

无法参数化索引查询的各个部分。在这种情况下,您必须使用整个索引查询作为单个参数,正如托马斯在Index parameterization in Cypher REST query

的第二个片段中所指出的那样