数组中对象的 ArangoDB 聚合计数
ArangoDB aggregation counts of objects in array
我正在尝试为图表中的以下文档生成构面(聚合计数)(基于集合而不是命名图表):
{
"relation": "decreases",
"edge_type": "primary",
"subject_lbl": "act(p(HGNC:AKT1), ma(DEFAULT:kin))",
"object_lbl": "act(p(HGNC:CDKN1B), ma(DEFAULT:act))",
"annotations": [
{
"type": "Disease",
"label": "cancer",
"id": "cancer"
},
{
"type": "Anatomy",
"label": "liver",
"id": "liver"
}
]
}
以下内容非常适合获取 edge_type 的构面(聚合计数):
FOR doc in edges
COLLECT
edge_type = doc.edge_type WITH COUNT INTO edge_type_cnt
RETURN {edge_type, edge_type_cnt}
我尝试了以下方法来获取注释的计数[*]。键入值:
FOR doc in edges
COLLECT
edge_type = doc.edge_type WITH COUNT INTO edge_type_cnt,
annotations = doc.annotations[*].type WITH COUNT INTO anno_cnt
RETURN {edge_type, edge_type_cnt, annotations, anno_cnt}
这会导致错误 - 知道我做错了什么吗?谢谢!
感谢这个帖子:https://groups.google.com/forum/#!topic/arangodb/vNFNVrYo9Yo linked to from this Question: 为我指明了正确的方向。
FOR doc in edges
FOR anno in doc.annotations
COLLECT anno_type = anno.type WITH COUNT INTO anno_cnt
RETURN {anno_type, anno_cnt}
结果:
Anatomy 4275
Cell 2183
CellLine 2093
CellStructure 2081
Disease 2126
Organism 2075
TextLocation 2121
遍历边缘然后注释数组是我遗漏的关键。
我正在尝试为图表中的以下文档生成构面(聚合计数)(基于集合而不是命名图表):
{
"relation": "decreases",
"edge_type": "primary",
"subject_lbl": "act(p(HGNC:AKT1), ma(DEFAULT:kin))",
"object_lbl": "act(p(HGNC:CDKN1B), ma(DEFAULT:act))",
"annotations": [
{
"type": "Disease",
"label": "cancer",
"id": "cancer"
},
{
"type": "Anatomy",
"label": "liver",
"id": "liver"
}
]
}
以下内容非常适合获取 edge_type 的构面(聚合计数):
FOR doc in edges
COLLECT
edge_type = doc.edge_type WITH COUNT INTO edge_type_cnt
RETURN {edge_type, edge_type_cnt}
我尝试了以下方法来获取注释的计数[*]。键入值:
FOR doc in edges
COLLECT
edge_type = doc.edge_type WITH COUNT INTO edge_type_cnt,
annotations = doc.annotations[*].type WITH COUNT INTO anno_cnt
RETURN {edge_type, edge_type_cnt, annotations, anno_cnt}
这会导致错误 - 知道我做错了什么吗?谢谢!
感谢这个帖子:https://groups.google.com/forum/#!topic/arangodb/vNFNVrYo9Yo linked to from this Question:
FOR doc in edges
FOR anno in doc.annotations
COLLECT anno_type = anno.type WITH COUNT INTO anno_cnt
RETURN {anno_type, anno_cnt}
结果:
Anatomy 4275
Cell 2183
CellLine 2093
CellStructure 2081
Disease 2126
Organism 2075
TextLocation 2121
遍历边缘然后注释数组是我遗漏的关键。