将 neo4j 分析输出重定向到文件

redirect neo4j profiling output to file

我正在使用 cypher-shell 分析一个查询,因为根据 this post 它更容易比较。

我的命令如下(查询不同)。

sudo cypher-shell -a myip:myport -u myusr -p 'my_pwd' "EXPLAIN MATCH (t1:Node1{field:1})−[:rel1]−>
( : Node2 {ID :"01"})<−[:rel1]−(t2:Trip{Direction:0})
RETURN t1, t2 LIMIT 1;"

此命令将查询的分析打印到终端。但是,很难在终端上阅读,所以我试图将输出重定向到文件,例如:

sudo cypher-shell -a myip:myport -u myusr -p 'my_pwd' "EXPLAIN MATCH (t1:Node1{field:1})−[:rel1]−>
( : Node2 {ID :"01"})<−[:rel1]−(t2:Node2{field:0})
RETURN t1, t2 LIMIT 1;" >> out.txt

但是,生成的文件不包含分析,仅包含几行,例如:

Plan: "EXPLAIN"
Statement: "READ_ONLY"
Version: "CYPHER 3.5"
Planner: "COST"
Runtime: "INTERPRETED"
Time: 0

如何将 neo4j 分析输出重定向到文件?

在命令中添加 --format verbose 标志。

sudo cypher-shell -a myip:myport -u myusr -p 'my_pwd' --format verbose "EXPLAIN MATCH (t1:Node1{field:1})−[:rel1]−>
( : Node2 {ID :"01"})<−[:rel1]−(t2:Node2{field:0})
RETURN t1, t2 LIMIT 1;" >> out.txt
如果输出被重定向到文件,

cypher-shell 似乎默认为 --format plain

Example output for a different query but the same command as above - not sure it's that much more readable