簡體   English   中英

Cypher 查詢 Neo4J

[英]Cypher query Neo4J

我對 Neo4j 非常陌生,所以需要一些幫助現在發布在 ['covid19','china_flu','coronavirus'] 子版塊上。 此語法不起作用 u.username IN {match (c:User)

詢問

match (s:Subreddit)--(p:Post)--(u:User) 
where toLower(p.title) =~ '.*corona.*' 
and s.display_name IN ['covid19','china_flu','coronavirus']
and p.created_utc_str >= '2020-01-01'
and p.created_utc_str <= '2020-01-30'
and u.username IN {match (c:User)-[:Submitted]->(b:Post)-[:Submitted]->(t:Subreddit)
                    where t.display_name IN ['collapse' ,'science' ,'politics'] 
                    and p.created_utc_str < '2020-01-01'
                    return distinct c.username}
return distinct  s,p,u
order by p.created_utc_str 

任何幫助將不勝感激

我認為 WHERE IN 子句只接受列表,不接受子查詢。 我重寫了您的查詢,它在 Neo4j 4.0.3 上正確解析

// Collect the distinct users who posted to pre-COVID subreddits into 'cspUsers'    
match (c:User)-[:Submitted]->(b:Post)-[:Submitted]->(t:Subreddit)
                    where t.display_name IN ['collapse' ,'science' ,'politics'] 
                    and b.created_utc_str < '2020-01-01'
with collect(distinct c.username) as cspUsers
// Match users who posted into COVID subreddits who are also in 'cspUsers'
match (s:Subreddit)--(p:Post)--(u:User) 
where toLower(p.title) =~ '.*corona.*' 
and s.display_name IN ['covid19','china_flu','coronavirus']
and p.created_utc_str >= '2020-01-01'
and p.created_utc_str <= '2020-01-30'
and u.username IN cspUsers
return distinct  s,p,u
order by p.created_utc_str

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM