首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cypher到Neo4JClient Distinct收集

Cypher到Neo4JClient Distinct收集
EN

Stack Overflow用户
提问于 2013-09-13 06:21:08
回答 1查看 983关注 0票数 2

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

代码语言:javascript
复制
start n = node:node_auto_index(Name = "user1") match path = (n-[r:IS_MEMBER_OF_GROUP*]->b) return last(collect(distinct path));

但是,当将其改为Neo4JClient语法时:

代码语言:javascript
复制
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;

它会得到一个错误:

代码语言:javascript
复制
{"Value cannot be null.\r\nParameter name: uriString"}

从那里继续下去时:

代码语言:javascript
复制
 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查询?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-13 07:37:32

您返回的是一个PathsResult,而不是一个Node<>,所以如果您将查询更改为:

代码语言:javascript
复制
 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

您将得到结果,这将返回我对我的数据库运行查询所得到的结果,如果您特别希望这个帖子中的节点:获取PathsResults涵盖转换为实际节点和关系。

另一件事(这将有助于查询更好地执行,因为neo4j可以更容易地缓存执行计划)是,您可以通过以下操作更改start以使其使用参数:

代码语言:javascript
复制
.Start(new { n = Node.ByIndexLookup("node_auto_index", "Name", "user1")})
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18779512

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档