我有一个包含Employee数据的Neo4J数据库。每个员工都包含一个名称和部门。 某些部门名称在db中的字符串文字中包含括号。
EG。
Employee { name: "abcd", department: "Human Resources (Recruitment)" }
我需要搜索具有与用户搜索字符串完全匹配的部门的员工。这意味着如果有人搜索“人力资源(招聘)”,那么我应该在搜索结果中获得员工的记录。如果搜索不完全匹配,我不需要结果中的员工记录。
我尝试了以下密码查询,但它无效。
Match (e: Employee) where e.department = "Human Resources (Recruitment)" return e
如果我用CONTAINS替换=它可以正常工作,但我需要精确匹配而不是部分匹配。我已经尝试过以下事情,但似乎没有任何效果。
Match (e: Employee) where e.department = '"Human Resources (Recruitment)'" return e
Match (e: Employee) where e.department = "Human Resources \(Recruitment\)" return e
Match (e: Employee) where e.department = "`Human Resources (Recruitment)`" return e
任何帮助都将受到高度赞赏。
答案 0 :(得分:0)
完美无缺:
我跑了这些并且都奏效了。
create (:Employee { name: "abcd", department: "Human Resources (Recruitment)" });
MATCH (n:Employee) RETURN n LIMIT 25;
match (e:Employee { department: "Human Resources (Recruitment)" }) return *;
match (e:Employee) where e.department: "Human Resources (Recruitment)" return *;
create index on :Employee(department);
match (e:Employee) where e.department = "Human Resources (Recruitment)" return *