ERR redis module_error ai_generated true

ERR RedisGraph: Graph 'mygraph' does not exist. Use GRAPH.CREATE first.

ID: redis/redisgraph-module-error

Also available as: JSON · Markdown · 中文
92%Fix Rate
88%Confidence
1Evidence
2024-02-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.2.0 active
7.4.0 active
8.0.0 active

Root Cause

Attempting to run GRAPH.QUERY on a non-existent graph key without prior GRAPH.CREATE call.

generic

中文

尝试对不存在的图键执行 GRAPH.QUERY,而未先调用 GRAPH.CREATE。

Official Documentation

https://redis.io/docs/stack/graph/

Workarounds

  1. 95% success Create the graph first: GRAPH.CREATE mygraph. Then retry GRAPH.QUERY mygraph 'MATCH (n) RETURN n'.
    Create the graph first: GRAPH.CREATE mygraph. Then retry GRAPH.QUERY mygraph 'MATCH (n) RETURN n'.
  2. 85% success If using RedisGraph v2.12+, enable auto-create: CONFIG SET graph.auto_create 1. Then GRAPH.QUERY will auto-create the graph.
    If using RedisGraph v2.12+, enable auto-create: CONFIG SET graph.auto_create 1. Then GRAPH.QUERY will auto-create the graph.

中文步骤

  1. 先创建图:GRAPH.CREATE mygraph。然后重试 GRAPH.QUERY mygraph 'MATCH (n) RETURN n'。
  2. 如果使用 RedisGraph v2.12+,启用自动创建:CONFIG SET graph.auto_create 1。然后 GRAPH.QUERY 将自动创建图。

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Using GRAPH.QUERY with a non-existent graph name will auto-create it in some versions, but not in strict mode; this behavior is version-dependent and unreliable.

  2. 80% fail

    Renaming the graph key with RENAME will fail if the key doesn't exist; it doesn't solve the missing graph issue.