Neo4j clean install does not recognize "use", "download" on import

I just installed neo4j 2.1.3 (current latest version) on Mac. I started the server through bin neo4j start

and I can check through localhost:7474

that neo4j is working. Then I continued with the neo4j shell with the following code:

➜  bin  neo4j-shell
Welcome to the Neo4j Shell! Enter 'help' for a list of commands
NOTE: Remote Neo4j graph database service 'shell' at port 1337

neo4j-sh (?)$ MATCH (n)
> OPTIONAL MATCH (n)-[r]-()
> DELETE n,r;
+--------------------------------------------+
| No data returned, and nothing was changed. |
+--------------------------------------------+
8946 ms
neo4j-sh (?)$ CREATE CONSTRAINT ON (w:Word) ASSERT w.value IS UNIQUE;
+--------------------------------------------+
| No data returned, and nothing was changed. |
+--------------------------------------------+
131 ms
neo4j-sh (?)$ USING PERIODIC COMMIT
Unknown command 'using'
neo4j-sh (?)$ LOAD CSV FROM
Unknown command 'load'
neo4j-sh (?)$ "file:/Users/code/Downloads/w2.txt" AS line FIELDTERMINATOR '\t'
Unknown command '"file:/users/code/downloads/w2.txt"'
neo4j-sh (?)$ MERGE (w1:Word { value: line[1] })
> MERGE (w2:Word { value: line[2] })
> CREATE (w1)-[:LINK { value : toInt(line[0])} ]->(w2);
SyntaxException: line not defined (line 1, column 25)
"MERGE (w1:Word { value: line[1] })"

      

I am trying to create a bigrams graph, the csv file contains a list of words. First, I delete the current data to create a clean database from a CSV file. It works. Then I create a constraint so that all words are unique. So far, so good.

But then, for import, it doesn't seem to recognize the commands, which are clearly defined in the docs .

What am I doing wrong?

--- Edit 1 ---

I think there might be something wrong inside. Even when I copy the code from (docs) [ http://docs.neo4j.org/chunked/stable/cypherdoc-importing-csv-files-with-cypher.html] it will give me erros.

code

LOAD CSV WITH HEADERS FROM "http://docs.neo4j.org/chunked/2.1.3/csv/import/persons.csv" AS csvLine
CREATE (p:Person { id: toInt(csvLine.id), name: csvLine.name })

      

Mistake

➜  neo4j-v2.1.3  ./bin/neo4j-shell
Welcome to the Neo4j Shell! Enter 'help' for a list of commands
NOTE: Remote Neo4j graph database service 'shell' at port 1337

neo4j-sh (?)$ LOAD CSV WITH HEADERS FROM "http://docs.neo4j.org/chunked/2.1.3/csv/import/persons.csv" AS csvLine
Unknown command 'load'
neo4j-sh (?)$ CREATE (p:Person { id: toInt(csvLine.id), name: csvLine.name })
> ;
SyntaxException: Unknown function 'toInt' (line 1, column 24)
"CREATE (p:Person { id: toInt(csvLine.id), name: csvLine.name })"

      

--- Edit 2 ---

The previous error was telling me a fresh fresh install, which showed something even weirder. This script now works correctly in neo4j-shell

;

MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;

CREATE CONSTRAINT ON (w:Word) ASSERT w.value IS UNIQUE;
USING PERIODIC COMMIT
LOAD CSV FROM
  "file:/Users/code/Downloads/w2.txt"
  AS line
  FIELDTERMINATOR '\t'
MERGE (w1:Word { value: toString(line[1]) })
MERGE (w2:Word { value: toString(line[2]) })
CREATE (w1)-[:LINK { value : toInt(line[0])} ]->(w2);

      

But when it exited, I found that the neo4j server went offline / crashed. When me neo4j start

or the neo4j restart

server, I get the same errors again as before.

final editing

It turns out to be $ neo4j

running a version of neo4j, but previously removed. Hint for others, always make sure you are using $ bin/neo4j start

and $ bin/neo4j-shell

from the installation folder. Don't let $ neo4j start

or $ neo4j-shell

always work. What went wrong was that I was running the wrong server version, but the correct shell version. These two couldn't communicate perfectly with each other.

+3


source to share


2 answers


Perhaps this is some kind of version issue? So you have an older version of Neo4j installed? Perhaps this is confusing? Try cleaning all your neo4j installations (find the filenames with neo4j on your drive) and try to start over?

Also check that there are no more startup-daemon scripts for Neo4j.



How do you determine if your server has crashed in the second script? Maybe also check the log files in data / log / * and data / graph.db / messages.log

+2


source


You must either start a transaction (see for example here: http://docs.neo4j.org/chunked/stable/shell-commands.html#_example_dump_scripts

Or create a .cql Import file with your instructions and point that file when starting the shell.

For example import.cql file:

CREATE CONSTRAINT ON (n:Node) assert n.id IS UNIQUE;
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM FILE "file:///path-to-your-file" AS csv
CREATE (n:Node {id:toInt(csv.id)})

      

Then execute the import.cql statements with the wrapper:



// This assumes that the import.cql file is located in your Neo4j install dir
./bin/neo4j-shell -file import.cql

      

Here is the result I just ran on my current test DB:

absoluttly:graphdb ikwattro$ ./bin/neo4j-shell -file import.cql
+-------------------+
| No data returned. |
+-------------------+
Constraints added: 1
200 ms
+-------------------+
| No data returned. |
+-------------------+
Nodes created: 1
Properties set: 1
Labels added: 1
41 ms

      

Here are some useful links:

http://www.neo4j.org/graphgist?d788e117129c3730a042 http://jexp.de/blog/2014/06/using-load-csv-to-import-git-history-into-neo4j/

0


source







All Articles