我正在尝试为图表中的以下文档生成构面(聚合计数)(基于集合而不是命名图):
{
"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}
我尝试了以下方法来获取注释[*]的计数.type value:
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}
导致错误 - 任何想法我做错了什么?谢谢!
答案 0 :(得分:3)
感谢这个帖子:https://groups.google.com/forum/#!topic/arangodb/vNFNVrYo9Yo与此问题相关联:ArangoDB Faceted Search Performance指出了我正确的方向。
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
循环边缘然后注释数组是我错过的关键。