gpt4 book ai didi

neo4j - Cypher 到 Neo4JClient 不同收集

转载 作者:行者123 更新时间:2023-12-04 04:41:49 25 4
gpt4 key购买 nike

我正在尝试获取从基节点到其根节点的路径作为 1 行。 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;

它得到一个错误:
{"Value cannot be null.\r\nParameter name: uriString"}

从那里继续时:
 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"

} ] ]

}

如何将密码查询转换为 Neo4JClient 查询?

最佳答案

好吧,您返回的东西是 PathsResult不是 Node<> ,因此如果您将查询更改为:

 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

你会得到结果,如果你特别想要这个帖子的节点,这将返回我从对我的数据库运行查询中得到的结果: Getting PathsResults涵盖转换为实际节点和关系。

另一件事(这将有助于查询执行得更好,因为 neo4j 可以更轻松地缓存执行计划),您可以更改 start通过执行以下操作使其使用参数:
.Start(new { n = Node.ByIndexLookup("node_auto_index", "Name", "user1")})

关于neo4j - Cypher 到 Neo4JClient 不同收集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18779512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com