Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output status messages to the console from cypher neo4j-shell

I'm running some Neo4j cypher queries using neo4j-shell. They have long execution times as I am importing large CSV files.

I would like to output some messages to the console as each stage of the import completes, so that we can see the import progress at run-time without having to wait for the execution to complete.

I've checked the Cypher RefCard and can't find an example of this. Does cypher support outputting to the shell console window?

like image 858
Adam Avatar asked Apr 24 '15 16:04

Adam


2 Answers

I find it a really interesting topic. IMO the best way to achieve it in a powerful way is to write a server plugin :

  • You create a TransactionEventHandler that implements the TransactionEventHandler interface

  • You receive a TransactionData which represents what has been changed during the transaction

  • You can transform the changes into json

  • and finally write them to the logs

  • activate the logs in the appenders

like image 87
Christophe Willemsen Avatar answered Sep 19 '22 18:09

Christophe Willemsen


The "Return" string is printed twice since the first is the header, and the second is the content. You can use "AS" with backticks to change the header to make it look better:

MATCH (n) 
DETACH DELETE n;
RETURN "Existing data removed" AS `Action:`;

Even better, you can combine the operation output with the message:

MATCH (n) 
DETACH DELETE n
RETURN count(n) AS `Existing data removed:`;
like image 21
Y.L Avatar answered Sep 21 '22 18:09

Y.L