Neo4j 2.0 dump with double type

2019-07-08 15:06发布

问题:

On Neo4j 2.0 (community) when I dump a db with some nodes with Double type properties, I obtain a file with value in scientific notation : ex 1.43524185E8

On import of this file, the neo4j-shell fail with the following error :

Invalid input 'E': expected Digit, whitespace, '.', node labels, '[', "=~", IN, IS, '*', '/', '%', '^', '+', '-', '<', '>', "<=", ">=", '=', "<>", "!=", AND, XOR, OR, ',' or '}' (line 167, column 153)
"create (_30015:`organization`:`fr` {`capital`:1.43524185E8, })"
                                                         ^
    at org.neo4j.cypher.internal.compiler.v2_0.parser.CypherParser$$anonfun$parse$1.apply(CypherParser.scala:53)
    at org.neo4j.cypher.internal.compiler.v2_0.parser.CypherParser$$anonfun$parse$1.apply(CypherParser.scala:43)

It seem Double type are not correctly parsed.

Command used for dumping the db :

$ neo4j-shell -c "dump" > ito3.graph

Command used to import them (in an empty graph.db) :

$ neo4j-shell -file ito3.graph

Detail of affected properties :

neo4j-sh (__value_deleted__,30015)$ ls -v
...
*capital                  =[1.43524185E8] (double)     
...

回答1:

In java generally, scientific notation numbers don't parse to doubles. Here's a related forum posting describing how to use DecimalFormat to fix the issue.

I think the bottom line is that what you're giving cypher isn't a double, but a string, and since you're not putting quotes around the string, it's dying. You need to give it a valid numeric format there.



标签: neo4j dump