0
我正在neo4j中試驗日期。現在我想用ISODateString對我的結果進行排序。我創建了一個密碼查詢,如下所示:正確使用ORDER BY的困惑
MATCH(e:Expedition {id : "BJGYmzwZb"})-[pje]-(u:User)
WHERE (e)-[:POSSIBLY_JOINS_EXPEDITION]-(u) OR (e)-[:JOINS_EXPEDITION]-(u)
WITH e, u, apoc.date.parse(pje.createdAt, 's',"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") as date
ORDER by date
OPTIONAL MATCH(u)<-[invitee:POSSIBLY_JOINS_EXPEDITION]-(e)
OPTIONAL MATCH(u)-[attendee:JOINS_EXPEDITION]->(e)
OPTIONAL MATCH(u)-[applicant:POSSIBLY_JOINS_EXPEDITION]->(e)
RETURN date, {user: properties(u), isInvitee: COUNT(invitee) > 0, isApplicant: COUNT(applicant) > 0, isAttendee: COUNT(attendee) > 0} as u
返回的結果未正確排序。而以下查詢確實以正確的順序返回結果。我只是刪除了零件OPTIONAL MATCH
。
MATCH(e:Expedition {id : "BJGYmzwZb"})-[pje]-(u:User)
WHERE (e)-[:POSSIBLY_JOINS_EXPEDITION]-(u) OR (e)-[:JOINS_EXPEDITION]-(u)
WITH e, u, apoc.date.parse(pje.createdAt, 's',"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") as date
ORDER by date
RETURN date, {user: properties(u)} as u
有什麼建議我做錯了什麼?我是否需要與OPTIONAL MATCH
加入區別?
這是不行的,如果我不希望返回的日期。任何解決方法? (e) - [:POSSIBLY_JOINS_EXPEDITION] - (u)OR(e) - [:JOINS_EXPEDITION] – janwo
嘗試:'MATCH(e:Expedition {id:'BJGYmzwZb「}) - [pje] - (u:User) - (u) WITH e,u,apoc.date.parse(pje.createdAt,'s',「yyyy-MM-dd'T'HH:mm:ss.SSS'Z'」)as date OPTIONAL MATCH (u)< - [invitee:POSSIBLY_JOINS_EXPEDITION] - (e) OPTIONAL MATCH(u) - [出席者:JOINS_EXPEDITION] - >(e) 可選MATCH(u) - [申請者:POSSIBLY_JOINS_EXPEDITION] - >(e) WITH日期,u,被邀請人,申請人,與會者 ORDER BY date RETURN {user:properties(u),isInvitee:COUNT(invitee)> 0,isApplicant:COUNT(applicant)> 0,isAttendee:COUNT(attendee)> 0}作爲你' –
不幸的是,這是行不通的。 – janwo