Reputation: 13
I want to execute cypher queries within a Java process (link).
This worked fine for all queries like MATCH xyz RETURN n
, but whenever I want to execute and write execute an operation like CREATE
or SET
, an exception is thrown:
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)
Code fragment:
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);
Referenced Libraries:
Upvotes: 1
Views: 485
Reputation: 8731
The problem is coming from your cypher planner, in Neo4j's Documentation you can find out how cypher queries are executed.
The above sentence is showing your problem exactly:
By default, Neo4j 2.2 will use the cost planner for some queries, but not all. You can force it to use a specific planner by using the query.planner.version configuration setting (see dbms.cypher.planner), or by prepending your query with CYPHER planner=cost or CYPHER planner=rule. Neo4j might still not use the planner you selected — not all queries are solvable by the cost planner at this point. Note that using PLANNER COST or PLANNER RULE in order to switch between planners has been deprecated and will stop working in future versions.
To fix this, you can simply change, in your database configuration file, your cypher planner (see dbms.cypher.planner documentation for a guide).
Upvotes: 1