我想做一个像这样的查询
"match (x: Person {name: "Adam"}), (x)-[:friend *..n]-(y) return y"
其中n是某个参数。试图通过spring boot执行此操作
"match (x: Person {name: {name: "Adam"}}), (x)-[:friend *..{distance}]-(y) return y"
我有一个@Param(“名字”),@ Param(“距离”)......它告诉我
Parameter maps cannot be used in MATCH patterns (use a literal map instead, eg. "{id: {param}.id}")
哪个我无法理解,我怎么能做我想要的?
目前,您无法使用参数作为模式的长度。或者,您可以使用java.text.MessageFormat
:
int distance = 4;
String query = MessageFormat.format(
"match (x: Person {name: {name: "Adam"}}), (x)-[:friend *..{0}]-(y) return y",
distance);