Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于两个不同的where条件在neo4j中返回子查询_Neo4j - Fatal编程技术网

基于两个不同的where条件在neo4j中返回子查询

基于两个不同的where条件在neo4j中返回子查询,neo4j,Neo4j,我在SQL中有此查询: Select Id, CrawlerId,CrawlerName, (SELECT Count(*) from CrawlerResult cr where cr.CrawlerId = cs.CrawlerId and IsNew=1) as LastRunResult , (SELECT Count(*) from CrawlerResult cr where cr.CrawlerId = cs.CrawlerId ) as Tota

我在SQL中有此查询:

  Select Id, CrawlerId,CrawlerName,
 (SELECT Count(*) from CrawlerResult cr where cr.CrawlerId = cs.CrawlerId  and            IsNew=1) as LastRunResult ,
 (SELECT Count(*) from CrawlerResult cr where cr.CrawlerId = cs.CrawlerId  ) as TotalResult
  FROM CrawlerScheduler cs 

如何通过组合CrawlerScheduler和CrawlerResult节点将此查询转换为neo4j cypher?

我假设您已将SQL中的外键关系替换为cypher中的实际关系,并且您使用的是实际布尔值,而不是1和0?比如:

(:CrawlerScheduler)-[:RESULT]->(:CrawlerResult)
如果是这样,那么等效的密码查询可能如下所示:

MATCH (cs:CrawlerScheduler)
WITH cs, SIZE((cs)-[:RESULT]->()) as TotalResult
OPTIONAL MATCH (cs)-[:RESULT]->(cr)
WHERE cr.IsNew
WITH cs, TotalResult, COUNT(cr) as LastRunResult
RETURN cs.Id, cs.CrawlerId, cs.CrawlerName, LastRunResult, TotalResult
编辑


我将第二个匹配更改为可选匹配,以防调度程序没有结果或没有新结果。

这是我正在搜索的密码。非常感谢。工作正常