Neo4j / Cypher : order by and where, know the position of the result in the sort -


does possible have order "property" clause , "index/position" of result?

i mean, when using order sorting need able know position of result in sort.

imagine scoreboard 1 million user node, order on user node.score "name = user_name" , wan't know current rank of user. not find how using order ...

    start game=node(1)     match game-[:has_child_user]->user     user     order user.score     user     user.name = "my_user"     return user , "the position in sort"; 

the expected result :

node_user | rank

(i don't want fetch 1 million entries @ client side know current rank/position of node in order by!)

this functionality not exist today in cypher. have example of in sql? below fits bill? (just sketch, not working!)

(your code)

start game=node(1) match game-[:has_child_user]->user user order user.score 

(+ code)

with user, index() rank return user.name, rank;  

if have more thoughts or want start hacking on please open issue @ https://github.com/neo4j/neo4j/issues

for time being there work around can do:

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

for live example see: http://console.neo4j.org/?id=bela20


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -