Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-12-2022 04:55 AM
I would like to do the following:
I'm failing at step 2 (import) because the method withFixture() in Neo4jConfigurator does not allow multistatement cypher files to be loaded. I used apoc.export.cypher.query to export the data. I have not found any option to export the query to cypher file using only single statements. I have also tested exporting with apoc.export.cypher.graph.
I'd imagine creating tests based on bugs found in production to be a somewhat common pattern. If anyone knows how to do this, please let me know.
05-12-2022 09:23 AM
I use 'withFixture' with files that have many lines of cypher. Can you upload an example to look at and the code that has 'withFixture'?
05-13-2022 12:08 AM
Sure!
To load the data, I use the neo4j procedure template as is: GitHub - neo4j-examples/neo4j-procedure-template: Boilerplate code for building Procedures for Neo4j...
The issue seems to be in the structure of the cypher file generated by APOC.
In order to not leak any sensitive data, I've taken the first two lines and anonymized them:
CREATE INDEX FOR (node:NodeType1) ON (node.node_attr_1);
CREATE INDEX FOR (node:NodeType1) ON (node.node_attr_2);
This on its own gives the issue:
"org.neo4j.graphdb.QueryExecutionException: Expected exactly one statement per query but got: 2"
In the full example, these lines are followed by a constraint and then the unwind create pattern. To reiterate, this is with no modifications, straight from APOC export to file.
I've also already tried a few tips online like removing the semi-colon at the end of each line but new issues prop up like reuse of the same variables and such.
05-13-2022 11:41 AM
I played around with it. I see what you mean. I got the same error. This is what I observed:
The only solution I found to work was to create three separate cypher files, one for each CREATE INDEX command and a 3rd for the cypher to create my data. You execute them with three 'withFixture' calls when building your in memory neo4j instance.
05-15-2022 11:54 PM
Thanks, for the help. That makes it a bit tricky to work with on large production data unfortunately. I think I'll have to deep dive into the issue and construct my own graph that mimics the bug with as few nodes as possible. Perhaps that's for the best anyways.
For issue completion's sake (if someone has this problem too), I should mention that the cypher file will work if you load it into a production neo4j instance that you set up via docker or install on OS. It's not a solution for testability, but it's good enough for finding the bug.
05-16-2022 02:09 AM
It may be a bug in the cypher parser that doesn’t correctly understand terminating the ‘create index’ command, so it isn’t possible to have any subsequent commands following.
All the sessions of the conference are now available online