ERR redis module_error ai_generated true

ERR BF.EXISTS: Bloom filter 'myfilter' does not exist. Use BF.RESERVE first.

ID: redis/redisbloom-filter-exists-error

Also available as: JSON · Markdown · 中文
95%Fix Rate
84%Confidence
1Evidence
2024-03-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.2.0 active
7.4.0 active
8.0.0 active

Root Cause

Attempting to query a Bloom filter that has not been created with BF.RESERVE or BF.ADD.

generic

中文

尝试查询尚未通过 BF.RESERVE 或 BF.ADD 创建的布隆过滤器。

Official Documentation

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

Workarounds

  1. 95% success Create the Bloom filter first with desired parameters: BF.RESERVE myfilter 0.01 10000 (error_rate 1%, capacity 10k). Then retry BF.EXISTS.
    Create the Bloom filter first with desired parameters: BF.RESERVE myfilter 0.01 10000 (error_rate 1%, capacity 10k). Then retry BF.EXISTS.
  2. 90% success If you want auto-creation on first BF.ADD, use BF.ADD myfilter item1 (this creates the filter with default parameters). Then use BF.EXISTS.
    If you want auto-creation on first BF.ADD, use BF.ADD myfilter item1 (this creates the filter with default parameters). Then use BF.EXISTS.

中文步骤

  1. 先使用所需参数创建布隆过滤器:BF.RESERVE myfilter 0.01 10000(错误率 1%,容量 1 万)。然后重试 BF.EXISTS。
  2. 如果希望在首次 BF.ADD 时自动创建,请使用 BF.ADD myfilter item1(这将使用默认参数创建过滤器)。然后使用 BF.EXISTS。

Dead Ends

Common approaches that don't work:

  1. 60% fail

    Using BF.EXISTS on a non-existent key returns 0 in some older versions, but in strict mode (RedisBloom v2.4+) it raises an error; relying on silent fallback is version-dependent.

  2. 80% fail

    Using EXISTS myfilter only checks if the key exists as a generic key, not if it's a valid Bloom filter; it doesn't solve the type mismatch.