如何在进行图形查询时匹配 Neo4j 中的方括号?

How to match a square bracket in Neo4j while doing a graph query?

我正在尝试匹配一个图形对象,该对象的代码 属性 为 "code": ["DAF AR Index"]

查询 match (n:GenericProduct {code:["DAF AR Index"]}) return n; 按预期工作并返回对象,但我无法使用 CONTAINS 或正则表达式匹配对象。为了匹配一个左括号,我试过

match (n:GenericProduct)
where  n.code =~ '\[.*'
    return n;

带有双反斜杠的相同表达式 - n.code =~ '\[.*',最后带有

match (n:GenericProduct)
where  n.code contains '['
    return n;

但到目前为止没有成功。任何关于如何进行的建议将不胜感激。提前致谢。

已编辑:这是对列表中的单词进行部分搜索的方法。比方说,我们想在代码是一个列表的代码中找到“DAF”。

MATCH (n:GenericProduct)
WHERE ANY(cd in n.code where cd contains 'DAF' )
RETURN n

Where cd in n.code means it will check each item in n.code (list). then "contains" will check if any word is 'DAF' and lastly, "ANY" mean find at least one item on the list which has a word 'DAF'

======

方括号“[”不是code值的一部分,它表示code值是一个“列表”,它有一项名为:“DAF AR Index”。要在列表中查找项目(或元素),您可以执行以下操作:

match (n:GenericProduct)
where  "DAF AR Index" in n.code  
return n;

有两种方法可以找到具有特定 属性 存储为列表的节点:

使用 APOC 程序:

MATCH (n:GenericProduct)
WHERE apoc.meta.cypher.type(n.code) = "LIST OF STRING"
RETURN n

或者使用“hacky”密码:

MATCH (n:GenericProduct)
WHERE size(n.code + 11) = size(n.code) + 1 
RETURN n