优化 AWS Neptune (Gremlin) 弹性搜索查询

时间:2021-05-07 15:52:58

标签: amazon-web-services elasticsearch gremlin amazon-neptune

我有一个如下图详述的图形结构(有 900k 个顶点和 2.2m 边)。在 AWS Neptune 上运行。目的是返回一组与文本搜索匹配的项目 ID,并删除任何排除的项目(基于组中限制的项目、绑定到另一个组的“独家项目”项目,或已购买的项目)用户)。查询的当前性能是 550 毫秒到 700 毫秒,我需要将性能控制在 100 毫秒以下。

enter image description here

我理解通常要优化 Neptune 查询,您应该尝试使用本机步骤,例如在分析器中,它指出 Neptune 本身不支持 fold,但是删除折叠实际上会使性能变差(大约 950 毫秒)并导致警告 ChooseStep... is not Supported natively,同时删除 chooseStep 会进一步降低性能结果SelectOneStep(last,items) is not natively supported...

有没有办法使用 Neptune 原生步骤重写此查询或总体上提高性能?

   g.withSideEffect("Neptune#fts.endpoint", "elastic search endpoint")
    .V().hasLabel('item').has('*', 'Neptune#fts test_item')
    .aggregate('items')
    .V().hasLabel('group')
    .where(out('exclusive_item_edge'))
    .not(hasId('group_id'))
    .out('exclusive_item_edge')
    .dedup()
    .aggregate('excludedItems')
    .fold()
    .V("group_id")
    .out('group_restriction_edge')
    .choose(
      has('name', 'intersection_restriction'),
      out()
        .out()
        .groupCount()
        .unfold()
        .where(select(values).is(gt(1)))
        .select(keys),
      out().out()
    )
    .dedup()
    .not(in('exclusive_item_edge')
         .hasId(within("group_id")))
    .aggregate('excludedItems')
    .fold()
    .V("user_id")
    .out('user_item_purchase_edge')
    .dedup()
    .aggregate('excludedItems')
    .fold()
    .select('items')
    .unfold()
    .where(without('excludedItems'))
    .id()

0 个答案:

没有答案
相关问题