neo4j - 密码查询 Neo4J
问题描述
我对 Neo4j 非常陌生,因此需要一些帮助我正在尝试在 NeO4j 中执行以下查询 这个想法是提取所有在 2020 年 1 月 1 日之前在 ['collapse' ,'science' ,'politics'] 子版块上发帖的用户现在发布在 ['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
推荐阅读
- python - 调整 CIFAR10 图像大小时出现内存错误
- asp.net-core - 具有交叉引用的实体框架核心多个 DbContext
- web-deployment - 如何通过SSH在DigitalOcean中具有LAMP堆栈的多个液滴/服务器上自动部署代码?
- python - Python skimage 洪水填充不适用于加载的二值化图像
- audio - 如何使用 FFmpeg 从 iPhone 视频文件中导出音频?
- javascript - 如何从 axios.get 返回的 useState 更新初始状态
- go - Go subslice 指针引用
- javascript - Find Missing levels and fill it
- python - 从终端安装python包开始失败,无法建立新连接:[Errno -3]名称解析临时失败
- r - r ggplot - 在不丢失 geom_smooth 统计信息的情况下更改 x 轴刻度标签