{“SyntaxException:无效输入'{':期望标识符字符,空格

时间:2016-01-28 14:42:49

标签: neo4j neo4jclient

VB.NET程序,它加载几千个节点并建立它们之间的关系。我正在使用Neo4J C#Client(版本1.1.0.8)

其中一个命令是

TheConnection.GraphClient.Cypher.Match(
    "(user1:StartingPoint)",
    "(user2:Committee)"
).Where(
    Function(user1 As StartingPoint)
        user1.Id = KnowsID
).AndWhere(
    Function(user2 As Committee)
        user2.Id = KnownID
).Create(
    "user1-[r: Knows ]->user2"
).ExecuteWithoutResults()

出于各种业务逻辑的原因,我希望通过FECIDNumber匹配节点(它实际上是一个字符串,例如'C00530767')而不是ID。所以我改变了

  1. KnownID从Long到String
  2. user2.Id = KnownID
  3. 这给了我以下查询

    TheConnection.GraphClient.Cypher.Match(
        "(user1:StartingPoint)",
        "(user2:Committee)"
    ).Where(
        Function(user1 As StartingPoint)
            user1.Id = KnowsID
    ).AndWhere(
        Function(user2 As Committee) user2.FECIDNumber = KnownID
    ).Create(
        "user1-[r: Knows ]->user2"
    ).ExecuteWithoutResults()
    

    执行时抛出

    {"SyntaxException: Invalid input '{':expected an identifier character, whitespace, '?', '!', '.', node labels, '[', ""=~"", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', ""<>"", ""!="", '<', '>', ""<="", "">="", AND, XOR, OR or ')' (line 3, column 23 (offset: 95))" & vbLf & """AND (user2.FECIDNumber{p1}{p2} = {p3})" & vbCr & """" & vbLf & "                       ^"}
    

    当我进入Neo4J浏览器并运行

    MATCH (user:Committee) WHERE user.FECIDNumber = "C00530766" RETURN user
    

    它按预期返回节点。

    我认为错误的重要部分似乎是

    (line 3, column 23 (offset: 95))
      " & vbLf & """AND (user2.FECIDNumber{p1}{p2} = {p3})" & vbCr & """" & vbLf & " 
    

    看起来Neo4J C#Client正在抛出第二个参数{p2},但这只是猜测。

    有什么建议吗?

    修改1

    (我不知道我甚至可以提取原始查询文本)

    它正在返回

    MATCH (user1:StartingPoint), (user2:Committee)
    WHERE (user1.Id = 1)
    AND (user2.FECIDNumber"C00530766"false = 0)
    CREATE user1-[r: Knows ]->user2
    

    显然问题在于

    user2.FECIDNumber = KnownID).Create("user1-[r: Knows ]->user2")
    

    以某种方式生成

    user2.FECIDNumber"C00530766"false = 0
    

    想法?我应该使用不同的语法吗?我是否需要将FECIDNumber转换为其他类型?

    修改2

    现在生成相同的代码

    MATCH (user1:StartingPoint), (user2:Committee)
    WHERE (user1.Id = 1)
    AND (user2.FECIDNumber = "C00530766")
    CREATE user1-[r: Knows ]->user2 
    

    它创造了预期的关系。

    得奖.....

1 个答案:

答案 0 :(得分:1)

我已经发布了一个版本(1.1.0.26),它应该为你解决这个问题,它需要花几分钟时间让Nuget为它编制索引,所以从发布这个版本开始每小时给它1/2小时...

让我知道!