繁体   English   中英

数组中对象的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}

我尝试了以下操作以获取注解[*]。type值的计数:

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与此问题相关的链接: ArangoDB多面搜索性能为我指明了正确的方向。

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

遍历边缘,然后注释数组是我丢失的关键。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM