Neo4JClient Distinct Collect的密码

Neo4JClient Distinct Collect的密码,neo4j,cypher,neo4jclient,Neo4j,Cypher,Neo4jclient,我正在尝试获取从基本节点到其根节点的路径,作为一行。Cypher查询如下所示: start n = node:node_auto_index(Name = "user1") match path = (n-[r:IS_MEMBER_OF_GROUP*]->b) return last(collect(distinct path)); 但将其更改为Neo4JClient语法时: var k = clientConnection.Cypher .Start(n

我正在尝试获取从基本节点到其根节点的路径,作为一行。Cypher查询如下所示:

start n = node:node_auto_index(Name = "user1") match path = (n-[r:IS_MEMBER_OF_GROUP*]->b) return last(collect(distinct path));
但将其更改为Neo4JClient语法时:

var k = clientConnection.Cypher
                .Start(new { n = "node:node_auto_index(Name = 'user1')" })
                .Match("path = (n-[r:IS_MEMBER_OF_GROUP*]->b)")
                .ReturnDistinct<Node<Principles>>("last(collect(path))").Results;
从那里继续时:

 Neo4jClient encountered an exception while deserializing the response from the server. This is likely a bug in Neo4jClient.



Please open an issue at https://bitbucket.org/Readify/neo4jclient/issues/new



To get a reply, and track your issue, ensure you are logged in on BitBucket before submitting.



Include the full text of this exception, including this message, the stack trace, and all of the inner exception details.



Include the full type definition of Neo4jClient.Node`1[[IQS_Neo4j_TestGraph.Nodes.Principles, IQS Neo4j TestGraph, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].



Include this raw JSON, with any sensitive values replaced with non-sensitive equivalents:



{

  "columns" : [ "last(collect(path))" ],

  "data" : [ [ {

    "start" : "http://localhost:7474/db/data/node/3907",

    "nodes" : [ "http://localhost:7474/db/data/node/3907", "http://localhost:7474/db/data/node/3906", "http://localhost:7474/db/data/node/3905", "http://localhost:7474/db/data/node/3904" ],

    "length" : 3,

    "relationships" : [ "http://localhost:7474/db/data/relationship/4761", "http://localhost:7474/db/data/relationship/4762", "http://localhost:7474/db/data/relationship/4763" ],

    "end" : "http://localhost:7474/db/data/node/3904"

  } ] ]

}

如何将cypher查询转换为Neo4JClient查询?

嗯,您返回的是
路径结果
而不是
节点,因此如果您将查询更改为:

 var k = clientConnection.Cypher
            .Start(new { n = "node:node_auto_index(Name = 'user1')" })
            .Match("path = (n-[r:IS_MEMBER_OF_GROUP*]->b)")
            .ReturnDistinct<PathsResult>("last(collect(path))").Results; //<-- Change here

谢谢你的回答,它很有效。还有提示,将来也会这样做。使用Neo4J和cypher非常新(比如day或2 new)。我发现非常有用的一件事是分别存储查询和结果-这样我可以检查查询是否正确,所以
var query=client.Start(/**/).Return(/**/)然后
var results=query.results
然后,您可以在
var results
上放置一个断点,并在执行之前查看查询是什么!
 var k = clientConnection.Cypher
            .Start(new { n = "node:node_auto_index(Name = 'user1')" })
            .Match("path = (n-[r:IS_MEMBER_OF_GROUP*]->b)")
            .ReturnDistinct<PathsResult>("last(collect(path))").Results; //<-- Change here
.Start(new { n = Node.ByIndexLookup("node_auto_index", "Name", "user1")})