1

我正在做以下查询

neo4j-sh (?)$  start n=node(*) match n-[r:LIKES]->items with r,items set r.w= (r.ct-items.med)/items.iqr return r,items;
==> +-----------------------------------------------------------------------------------+
==> | r                                         | items                                 |
==> +-----------------------------------------------------------------------------------+
==> | :LIKES[293] {ct:3,w:-0.6666666666666666}  | Node[255]{name:"f1",iqr:6.0,med:7}    |
==> | :LIKES[294] {ct:13,w:1}                   | Node[256]{name:"f2",iqr:5,med:7}      |
==> | :LIKES[295] {ct:1,w:-0.7692307692307693}  | Node[257]{name:"f3",iqr:3.25,med:3.5} |
==> | :LIKES[304] {ct:3,w:0}                    | Node[256]{name:"f2",iqr:5,med:7}      |
==> | :LIKES[305] {ct:10,w:0.5}                 | Node[255]{name:"f1",iqr:6.0,med:7}        
==> | :LIKES[308] {ct:9,w:0.4}                  | Node[259]{name:"f5",iqr:7.5,med:6.0}  |
==> | :LIKES[313] {ct:2,w:-1}                   | Node[256]{name:"f2",iqr:5,med:7}      |
==> | :LIKES[314] {ct:3,w:-0.6666666666666666}  | Node[255]{name:"f1",iqr:6.0,med:7}    |
==> +-----------------------------------------------------------------------------------+ 

为什么当 rw 的值大于 1 时,会四舍五入到最接近的整数?我试图将其类型转换为双倍,但出现错误。那么正确的设置命令是什么?

4

1 回答 1

3

使用浮点数让它做浮点数学:

start n=node(*) match n-[r:LIKES]->items with r set r.w= (r.ct-1.0)/5.0 return r;
于 2013-06-11T18:11:23.850 回答