我正在尝试使用来自Spring数据neo4j的like运算符在neo4j Cypher Query中传递参数。请告诉我正确的方式传递参数与操作..请帮助我。
Map<String, Object> map = new HashMap<String, Object>();
map.put(queryAfterSubstutuet(collabVo),
groupIdAfterSubstituet(collabVo));
map.put("display_name",input);
Result<Map<String, Object>> result = neoOperation.query(
collabVo.getSearchQuery(), map);
我的getSearchQuery
MATCH (n:OrganizationUnit {id:{class}})-[r:PART]-(c)-[r1:STUDENTROLE]-(f) where f.firstName =~"{display_name}.*" RETURN f
但它引发了错误
Caused by: java.util.regex.PatternSyntaxException: Illegal repetition
[STDERR] {display_name}.*
[STDERR] at java.util.regex.Pattern.error(Pattern.java:1924)
[STDERR] at java.util.regex.Pattern.closure(Pattern.java:3104)
[STDERR] at java.util.regex.Pattern.sequence(Pattern.java:2101)
[STDERR] at java.util.regex.Pattern.expr(Pattern.java:1964)
[STDERR] at java.util.regex.Pattern.compile(Pattern.java:1665)
[STDERR] at java.util.regex.Pattern.<init>(Pattern.java:1337)
[STDERR] at java.util.regex.Pattern.compile(Pattern.java:1022)
答案 0 :(得分:2)
如果您将查询更改为:
MATCH (n:OrganizationUnit {id:{class}})-[r:PART]-(c)-[r1:STUDENTROLE]-(f)
where f.firstName =~{display_name} RETURN f
并添加到您的参数
map.put("display_name",input);
其中input包含完整模式(如input =&#34; nameToMatch。*&#34;),这应该有效。