Skip to content

[Question] Document the index requirement for global Gremlin has() property queries #577

Open

Description

@choeoe

Problem Type (问题类型)

lack info (文档描述缺失)

Your Question (问题描述)

The HugeGraph 1.7 Gremlin guide lists has as a supported filtering step. The 1.7 Java Client guide gives examples of property queries backed by indexes, but I could not find an explicit rule explaining when a global g.E()/g.V() property query requires an index, or that an unindexed query may fail with NoIndexException even if only one matching edge exists.

On HugeGraph 1.7.0, the index requirement appears to depend on the traversal's starting point: the global query below fails, while a traversal from a known vertex using the same has() predicate succeeds. Is this intended? If so, could the Gremlin guide state the condition and show the alternative of starting from a known vertex or creating an appropriate index?

Environment: HugeGraph 1.7.0 (hugegraph/hugegraph:1.7.0 Docker image), default test backend, Gremlin HTTP endpoint. No index label is created in the reproduction.

Reproduction: Create an edge label whose schema includes tag, then insert one edge with tag = 'x':

schema = graph.schema()
schema.propertyKey('name').asText().ifNotExist().create()
schema.propertyKey('tag').asText().ifNotExist().create()
schema.vertexLabel('DGDocVertex').properties('name').primaryKeys('name').ifNotExist().create()
schema.edgeLabel('DGDocEdge').sourceLabel('DGDocVertex').targetLabel('DGDocVertex').properties('tag').ifNotExist().create()
a = graph.addVertex(T.label, 'DGDocVertex', 'name', 'doc-a')
b = graph.addVertex(T.label, 'DGDocVertex', 'name', 'doc-b')
a.addEdge('DGDocEdge', b, 'tag', 'x')
graph.tx().commit()
g = graph.traversal()

g.E().hasLabel('DGDocEdge').count()                       // 1
g.E().hasLabel('DGDocEdge').has('tag', P.eq('x')).count() // NoIndexException
g.V(a.id()).outE().has('tag', P.eq('x')).count()         // 1

The global query reports that properties [tag] are not indexed in edge label DGDocEdge and may not match the secondary condition. With P.without('z'), the analogous global query also raises NoIndexException, while g.V(a.id()).outE().has('tag', P.without('z')).count() returns 1.

The original test report hugegraph-2-analysis-doc-gap.md also observed NoIndexException for g.E().filter(__.has('tag', P.without('x'))). The complete fixture above shows that the failure is not caused by an undefined property key, an edge label that omits tag, or an empty graph.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions