SDN Neo4j Cypher 不区分大小写的查询

SDN Neo4j Cypher case insensitive query

我有一个 Spring Data Neo4j(3.4.0.RELEASE) 实体,其中包含 indexed 属性 name:

@NodeEntity
public class Decision {

    @Indexed
    private String name;
    ....

我需要通过 name 属性 实现不区分大小写的搜索。

在我的 DecisionRepository 中,我创建了以下方法:

@Query("MATCH (d:Decision) WHERE d.name =~ '(?i){name}' RETURN d")
Decision findByNameIgnoreCase(@Param("name") String name);

但执行后出现以下异常:

org.springframework.dao.InvalidDataAccessApiUsageException: Illegal repetition near index 3
(?i){name}
   ^; nested exception is java.util.regex.PatternSyntaxException: Illegal repetition near index 3
(?i){name}
   ^

如何对名称 属性 实施正确的不区分大小写的搜索?

我知道这有点棘手,但我猜你可以在注释中使用这个查询来做到这一点:

MATCH (d:Decision) WHERE LOWER(d.name) = LOWER({name}) RETURN d

如果您将两个名称(参数和值)都设置为小写,则大小写无关紧要。

要完全按照您的意愿进行(正则表达式匹配),您必须使用 //:

MATCH (d:Decision) WHERE d.name =~ /(?i){name}/ RETURN d

如果有效请告诉我。