# BF.EXISTS：布隆过滤器 'myfilter' 不存在。请先使用 BF.RESERVE。

- **ID:** `redis/redisbloom-filter-exists-error`
- **领域:** redis
- **类别:** module_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.2.0 | active | — | — |
| 7.4.0 | active | — | — |
| 8.0.0 | active | — | — |

## 解决方案

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

## 无效尝试

- **** — 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. (60% 失败率)
- **** — 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. (80% 失败率)
