我有一個大的Cypher查詢,我收集了一些信息片段在我的應用程序的視圖。在一部分中,我使用可選匹配來獲得即將到來的聚會,但是我需要他們在進入COLLECT之前通過ASC訂購,並使用WITH語句向前傳遞。我試圖將它添加到WHERE子句的下面,顯然,它會拋出一個錯誤。ORDER BY之前收集和與
有沒有辦法在可選MATCH或COLLECT語句中進行排序?
這是我的Cypher查詢
MATCH (o:Person)<-[:OWNED_BY]-(g:Group {group_slug:"'.$group_slug.'"})<-[:MEMBER_OF]-(m:Person)-[:JOB_TITLE]->(title:Title)
WITH o,g,COLLECT({first_name: m.first_name, last_name: m.last_name, image_name: m.image_name, username: m.username, job_title: title.job_title}) as members,title,COUNT(m) as member_count
OPTIONAL MATCH (g)-[:TOPIC_OF]->(t:Topic)
WITH o,members,g,COLLECT(DISTINCT t.name) as topics,title,member_count
OPTIONAL MATCH (g)-[:CREATED]->(mu:Meetup{status:"Active"})-[:MEETUP_AT]->(l:Location)
WHERE toInt(mu.meet_date) >= '.time().'
WITH o,members,g,title,topics,COLLECT({location_name:l.location_name, address:l.address,city:l.city,state:l.state,zip_code:l.zip_code,meet_date:mu.meet_date,meeting_id:id(mu)}) as meetups,member_count
OPTIONAL MATCH (g)-[]->(amu:Meetup)
WITH o,members,g,title,topics,meetups,COUNT(amu) as meetup_count,member_count
OPTIONAL MATCH (g)<-[:REQUESTED]-(pm:Person)-[:JOB_TITLE]->(pmt:Title)
WITH o,members,g,title,topics,meetups,meetup_count,COLLECT({first_name: pm.first_name, last_name: pm.last_name, image_name: pm.image_name, username: pm.username, job_title: pmt.job_title}) as requested,member_count
OPTIONAL MATCH(g) <-[:FAVORITED]-(fp:Person)
WITH o,members,g,title,topics,meetups,meetup_count,requested,COUNT(fp) as favorited,member_count
RETURN o.username as owner_username, o.first_name as owner_first, o.last_name as owner_last, g.group_name as group_name, g.description as description, g.access as access, g.group_slug as group_slug,
topics, members,meetups,meetup_count, favorited,requested,member_count
其中違規查詢部分是
OPTIONAL MATCH (g)-[:CREATED]->(mu:Meetup{status:"Active"})-[:MEETUP_AT]->(l:Location)
WHERE toInt(mu.meet_date) >= time()
什麼是錯誤訊息?另外請注意,timestamp函數是'timestamp()'而不是'time()'。 –
時間()是PHP。對不起,我沒有指定 –