'ORDER BY' results per row in cypher query(Neo4j)

时光怂恿深爱的人放手 提交于 2019-12-13 03:54:55

问题


This question is a follow on to the question here

With 2 answers for that

Now I need to modify this query to return those items related to this HashTag, order by createdDate(as all those items have createdDate property).

I've written this query:

MATCH (r:RateableEntity)<-[:TAG]-(h:HashTag:Featured)
WITH h, COUNT(h) AS Count
  ORDER BY Count DESC
  SKIP 2
  LIMIT 3
WITH h, Count, h.tag as Name,
     [(h)-[:TAG]->(m:RateableEntity {audience: 'world'}) | m][..3] AS Items 
UNWIND Items as row
RETURN row, Name, Count, COLLECT(row.id)
 ORDER BY row.createdDate

But the results are:

Name          row.id                                  Count
"vanessa"     "cdd14968-404c-41e9-84d5-bf147030a023"  14
"vanessa"     "qwd14968-2344-41e9-84d5-bftt34534566"  14
"vanessa"     "cd14968-404c-41e9-84d5-certt4545455g"  14
"hash"        "b7e74f38-44e4-4b7f-b2c4-8301023ffa9b"  15
"hash"        "edr34334-2995-4202-b178-bb2a6f230ab0"  15
"hash"        "htth5548-404c-41e9-84d5-bf147030a023"  15
"new"         "oljj4968-2344-41e9-84d5-bftt34534566"  3
"new"         "werr4968-404c-41e9-84d5-certt4545455"  3
"new"         "be545b38-44e4-4b7f-b2c4-8301023ffa9b"  3

I can see that count is correct andskip and limit working as I want but here I have 3 rows instead of one row and 3 id. Also ORDER BY is not working.

Any idea? ideas appreciated.

UPDATE:

Actually the result of this query will be nodes and after that, in my code, I'm mapping to this, so still it's not what I want

来源:https://stackoverflow.com/questions/55447197/order-by-results-per-row-in-cypher-queryneo4j

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!