You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cypher查询需求:HPKP节点关联Issue的属性求和与分组过滤

Cypher Query to Calculate Total Worklog for HPKP-X Associated Nodes (Excluding relates Relationships)

Got it, let's refine your query to hit exactly what you need. Here's the polished solution:

Final Cypher Query

MATCH c = (p:Project{key:"HPKP"})-[r:CONTAINS]->(hpkpXIssue:Issue)-[*]-(relatedIssue:Issue)
WHERE NONE(rel IN relationships(c) WHERE type(rel) = 'relates')
RETURN hpkpXIssue.key AS hpkpXNode, SUM(relatedIssue.worklog) AS totalWorklog
GROUP BY hpkpXIssue.key

Step-by-Step Breakdown

  • MATCH Clause: We start at the Project node with key "HPKP", traverse the CONTAINS relationship to grab its direct child issues (your HPKP-X nodes). Then we match all arbitrary-depth paths from these HPKP-X nodes to other Issue nodes.
  • WHERE Clause: The NONE() function acts as a filter to ensure no relationship in the entire path c is of type relates—this cuts out any paths that include the unwanted relationship type entirely.
  • RETURN + GROUP BY: We group results by each HPKP-X node's key, then calculate the sum of the worklog property from all associated relatedIssue nodes.

Optional: Exclude the HPKP-X Node Itself

If you don't want the HPKP-X node's own worklog included in the total, add an extra condition to the WHERE clause:

MATCH c = (p:Project{key:"HPKP"})-[r:CONTAINS]->(hpkpXIssue:Issue)-[*]-(relatedIssue:Issue)
WHERE NONE(rel IN relationships(c) WHERE type(rel) = 'relates')
  AND hpkpXIssue <> relatedIssue
RETURN hpkpXIssue.key AS hpkpXNode, SUM(relatedIssue.worklog) AS totalWorklog
GROUP BY hpkpXIssue.key

This ensures we only sum worklogs from nodes connected to HPKP-X, not the HPKP-X node itself.

内容的提问来源于stack exchange,提问作者Eugen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:07:15