我想在Java进程(link)中执行密码查询。

这对于MATCH xyz RETURN n之类的所有查询都可以正常工作,但是每当我要执行和编写执行CREATESET之类的操作时,都会引发异常:

Exception in thread "main" org.neo4j.graphdb.QueryExecutionException: The given query is not supported at the moment in the selected cost-based planner
at org.neo4j.kernel.impl.query.QueryExecutionKernelException.asUserException(QueryExecutionKernelException.java:35)
at org.neo4j.kernel.InternalAbstractGraphDatabase.execute(InternalAbstractGraphDatabase.java:970)
at org.neo4j.kernel.InternalAbstractGraphDatabase.execute(InternalAbstractGraphDatabase.java:957)
at MainClass.embTestQuery(MainClass.java:85)
at MainClass.main(MainClass.java:28)


代码片段:

    matchingQuery = "CREATE (n:testnode) RETURN n";
    try ( Transaction ignored = db.beginTx();
              Result result =
                      db.execute( matchingQuery ))
        {
            while ( result.hasNext() )
            {
                Map<String,Object> row = result.next();
                for ( Entry<String,Object> column : row.entrySet() )
                {
                    rows += column.getKey() + ": " + column.getValue() + "; ";
                }
                rows += "\n";
            }
        }
    System.out.println(rows);


引用的库:


neo4j-consistency-check-2.2.5.jar
neo4j-csv-2.2.5.jar
neo4j-cypher-2.2.5.jar
neo4j-cypher-compiler-1.9-2.0.4.jar
neo4j-cypher-compiler-2.0-2.0.4.jar
neo4j-cypher-compiler-2.1-2.1.8.jar
neo4j-cypher-compiler-2.2-2.2.5.jar
neo4j-graph-algo-2.2.5.jar
neo4j-graph-matching-2.2.5.jar
neo4j-import-tool-2.2.5.jar
neo4j-io-2.2.5.jar
neo4j-jmx-2.2.5.jar
neo4j-kernel-2.2.5.jar
neo4j-lucene-index-2.2.5.jar
neo4j-primitive-collections-2.2.5.jar
lucene-core-3.6.2.jar
org.apache.servicemix.bundles.jline-0.9.94_1.jar
neo4j-shell-2.2.5.jar
neo4j-udc-2.2.5.jar
neo4j-unsafe-2.2.5.jar

最佳答案

问题来自密码计划器,在Neo4j's Documentation中,您可以找到密码查询的执行方式。

上面的句子正好显示了您的问题:


  默认情况下,Neo4j 2.2将对某些查询(而非全部查询)使用成本计划器。您可以通过使用query.planner.version配置设置(请参阅dbms.cypher.planner),或通过在查询之前添加CYPHER planner = cost或CYPHER planner = rule来强制它使用特定的计划程序。 Neo4j可能仍不使用您选择的计划程序—此时,并非所有查询都可以由成本计划程序解决。请注意,不建议使用PLANNER COST或PLANNER RULE来在计划者之间进行切换,并且它将在以后的版本中停止工作。


修复

要解决此问题,您只需在数据库配置文件中更改密码计划程序即可(有关指南,请参见dbms.cypher.planner documentation)。

10-05 23:27