2013-08-20 87 views
0

我想执行类似的Cypher查询:您可以在通过REST API传递的多索引查找密码查询中使用参数吗?

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

还有一个关于[参数化索引查找]的问题(http://stackoverflow.com/questions/16717225/index -parameterization-in-cypher-rest-query/16720980#16720980),这是否适合你的问题? –

+0

不,因为这是单个参数,它可以正常工作,这是专门针对多个参数。 –

回答

2

这是不可能的参数化部分索引查询。在这种情况下,您必须将整个索引查询用作单个参数,如Thomas在第二段中指出的Index parameterization in Cypher REST query

+0

我明白了,所以参数化整个查询,感谢您在上下文中指出解决方案 - 这是一个没有看到树木的情况。 –

相关问题