Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j/Cypher:order by和where,知道结果在排序中的位置_Neo4j_Cypher - Fatal编程技术网

Neo4j/Cypher:order by和where,知道结果在排序中的位置

Neo4j/Cypher:order by和where,知道结果在排序中的位置,neo4j,cypher,Neo4j,Cypher,是否可以使用where子句和结果的“索引/位置”按“属性”排序 我的意思是,当使用排序时,我们需要知道排序结果在排序中的位置 想象一个有一百万用户节点的记分板,我在用户节点上做了一个order by.score,其中有一个“name=user\u name”,我不想知道用户的当前排名。我找不到如何使用order by start game=node(1) match game-[:has_child_user]->user with user order b

是否可以使用where子句和结果的“索引/位置”按“属性”排序

我的意思是,当使用排序时,我们需要知道排序结果在排序中的位置

想象一个有一百万用户节点的记分板,我在用户节点上做了一个order by.score,其中有一个“name=user\u name”,我不想知道用户的当前排名。我找不到如何使用order by

    start game=node(1)
    match game-[:has_child_user]->user
    with user
    order by user.score
    with user
    where user.name = "my_user"
    return user , "the position in the sort";
预期结果将是:

节点|用户|等级


(我不想在客户端获取一百万个条目来了解ORDER BY中节点的当前排名/位置!)

此功能目前在Cypher中不存在。您有没有一个例子来说明这在SQL中是什么样子的?下面的内容是否符合要求?(只是草图,不起作用!)

(你的代码)

(+此代码)

如果你有更多的想法或想开始对此进行黑客攻击,请在

目前,您可以做以下工作:

start n=node(0),rank_node=node(1) 
match n-[r:rank]->rn 
where rn.score <= rank_node.score 
return rank_node,count(*) as pos;
start n=node(0),rank\u node=node(1)
匹配n-[r:rank]->rn

谢谢你,它工作得很好。。。但我认为解决办法是O(n*n)复杂度?
with user, index() as rank
return user.name, rank; 
start n=node(0),rank_node=node(1) 
match n-[r:rank]->rn 
where rn.score <= rank_node.score 
return rank_node,count(*) as pos;