# BF.ADD

> Add an item to a Bloom filter, creating the filter if needed.

URL: https://docs.hotkv.com/commands/bf-add/

```
BF.ADD key item
```

- Group: Bloom filter
- Complexity: O(k), k being the number of hash functions
- HotKV Cloud: all plans
- On-Premise: no license needed

`BF.ADD` adds `item` to the Bloom filter at `key`. If the key does not exist,
a filter is created first with capacity 100, error rate 0.01 and expansion 2.
Use [BF.RESERVE](https://docs.hotkv.com/commands/bf-reserve/index.md) or [BF.INSERT](https://docs.hotkv.com/commands/bf-insert/index.md)
for other settings.

The reply tells you whether the item is new. Because Bloom filters can give
false positives, a new item is occasionally reported as already present.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Item added | Integer `1` | Boolean true |
| Item (probably) already present | Integer `0` | Boolean false |

Error replies:

- `ERR non scaling filter is full` when a non-scaling filter already holds its capacity.
- `ERR Insufficient memory to grow the filter` or `ERR Insufficient memory to create filter`.
- `WRONGTYPE` if the key holds another type.

## Examples

```
127.0.0.1:6379> BF.ADD visitors alice
(integer) 1
127.0.0.1:6379> BF.ADD visitors alice
(integer) 0
127.0.0.1:6379> BF.EXISTS visitors alice
(integer) 1
```

## Compatibility

Same as `BF.ADD` in RedisBloom, including the default filter settings.

## See also

[BF.MADD](https://docs.hotkv.com/commands/bf-madd/index.md), [BF.INSERT](https://docs.hotkv.com/commands/bf-insert/index.md), [BF.EXISTS](https://docs.hotkv.com/commands/bf-exists/index.md),
[BF.RESERVE](https://docs.hotkv.com/commands/bf-reserve/index.md), [BF.CARD](https://docs.hotkv.com/commands/bf-card/index.md)