neo4j / neo4j

Graphs for Everyone
http://neo4j.com
GNU General Public License v3.0
13.36k stars 2.38k forks source link

Neo4j 2.2 Transaction Endpoint: Forcing Cypher Planner Not Supported #4461

Closed bunkat closed 9 years ago

bunkat commented 9 years ago

Due to issues with the COST planner, I tried to force the RULE planner for queries that are executed as part of a transaction (as my application normally does vs testing in the web interface).

In the web interface, this works as expected:

  PLANNER RULE
  MATCH (t:task {id: "foobar" })
  RETURN t

But when attempted within a transaction that hits the HTTP Cypher query transaction endpoint, I get this instead:

E0417 15:31:34.034783 8953 transaction.go:206] Transaction Get Task failed with errors E0417 15:31:34.034816 8953 transaction.go:207] [{Neo.ClientError.Statement.InvalidSyntax Invalid input 'P': expected (line 1, column 1 (offset: 0)) "PLANNER RULE" ^}] E0417 15:31:34.034837 8953 transaction.go:210] PLANNER RULE

Based on a comment in another issue, I have to do this instead which seems to force the query planner to use the RULE planner.

  MATCH (t:task {id: "foobar" })
  RETURN t SKIP 0
jexp commented 9 years ago

It works for me:

:POST /db/data/transaction/commit {"statements":[{"statement":"planner rule match n return n limit 1"}]}

:POST /db/data/transaction/commit {"statements":[{"statement":"planner rule match n return n limit 1"}]}
{
  "results": [
    {
      "columns": [
        "n"
      ],
      "data": [
        {
          "row": [
            {
              "fileName": "/Users/mh/java/software/jqassistant/distribution/target/distribution/plugins"
            }
          ]
        }
      ]
    }
  ],
  "errors": []
}

Otherwise can you try to use CYPHER 2.2 PLANNER RULE ....

bunkat commented 9 years ago

Neither PLANNER RULE nor CYPHER 2.2 PLANNER RULE are working for me. I posted my raw query at https://gist.github.com/bunkat/d7b4fb691d6f609989c5. I double checked and am hitting the correct URL with the correct POST operation. Is there a setting somewhere I might need to change?

jexp commented 9 years ago

And the correct Neo4j version I presume? (2.2+)

I thought it was related to your prepended \n but even that works for me:

:POST /db/data/transaction/commit {"statements":[{"statement":"\n planner rule match n return n limit 1"}]}

even with curl

curl -H accept:application/json -H content-type:application/json -d'{"statements":[{"statement":"\n planner rule match n return n limit 1"}]}' http://localhost:7474/db/data/transaction/commit

{"results":[{"columns":["n"],"data":[{"row":[{"fileName":"/Users/mh/java/software/jqassistant/distribution/target/distribution/plugins"}]}]}],"errors":[]}
bunkat commented 9 years ago

Yep, I'm running 2.2.0 currently. Is this something that was fixed in 2.2.1?

Your curl statement fails for me:

curl -H accept:application/json -H content-type:application/json -d'{"statements":[{"statement":"\n planner rule match n return n limit 1"}]}' http://localhost:7474/db/data/transaction/commit

{"results":[],"errors":[{"code":"Neo.ClientError.Statement.InvalidSyntax","message":"Invalid input 'p': expected (line 1, column 1 (offset: 0))\n\"planner rule match n return n limit 1\"\n ^"}]}

jexp commented 9 years ago

Oh yes, sorry I am running 2.2.1

bunkat commented 9 years ago

Confirmed that this is resolved in 2.2.1.