【问题标题】:Neo4j Cypher could not match string parenthesisNeo4j Cypher 无法匹配字符串括号
【发布时间】:2016-02-28 03:47:14
【问题描述】:

我有一个包含 Employee 数据的 Neo4J 数据库。每个员工都包含一个姓名和部门。 一些部门名称在数据库中的字符串文字中包含括号。

例如。

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

我们将不胜感激任何帮助。

【问题讨论】:

  • 它应该开箱即用。您对该值有索引/约束吗?
  • 您的第一个查询是有效的,它应该可以工作。我刚刚创建了相同的节点,您的查询返回了有效结果。您确定部门字段中没有不可见字符、空格字符之类的垃圾吗?

标签: neo4j cypher


【解决方案1】:

工作得很好:

我运行了这些,一切正常。

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 *

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-11
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-22
    相关资源
    最近更新 更多