【问题标题】:Using index in DSE graph在 DSE 图中使用索引
【发布时间】:2017-07-11 03:18:56
【问题描述】:

我正在尝试获取与其他人具有相同地址且人数在 3 到 5 之间的数据税图中的人员列表。 这是查询:

g.V().hasLabel('person').match(__.as('p').out('has_address').as('a').dedup().count().as('nr'),__.as('p').out('has_address').as('a')).select('nr').is(inside(3,5)).select('p','a','nr').range(0,20)

在第一次运行时我注意到了这个错误消息:

找不到回答查询子句的索引,graph.allow_scan 是 禁用:((标签=人))

我已启用 graph.allow_scan=true,现在它可以工作了

我想知道如何在不启用 allow_scan=true 的情况下创建能够运行此查询的索引?

谢谢

【问题讨论】:

    标签: datastax datastax-enterprise gremlin datastax-enterprise-graph


    【解决方案1】:

    您可以使用如下命令将索引添加到架构中来创建索引:

    schema.vertexLabel('person').index('address').materialized().by('has_address').add()
    

    此处提供了有关添加索引的完整文档:https://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/using/createIndexes.html

    您不应启用 graph.allow_scan=true,因为它在 CQL 查询上打开了 ALLOW FILTERING。这将导致大量集群扫描,并且不可避免地会因系统中的任何实际数据量而超时。您永远不应在任何类型的生产环境中启用此功能。

    【讨论】:

      【解决方案2】:

      我不确定索引是否能解决您的问题。 最好的方法是将地址具体化为节点,并寻找入度在 3 到 5 之间的节点。

      您可以在地址节点的文本字段上使用索引。

      【讨论】:

        猜你喜欢
        • 2017-05-27
        • 2016-06-03
        • 2018-04-25
        • 2017-05-25
        • 2016-11-26
        • 2020-07-28
        • 2016-12-15
        • 1970-01-01
        • 2013-09-30
        相关资源
        最近更新 更多