# VSIM.SET

> Store or replace the vector for a key in a vector index.

URL: https://docs.hotkv.com/commands/vsim-set/

```
VSIM.SET index key value [value ...]
```

- Group: Vector search
- Complexity: O(log N) on average, N being the vectors in the index
- HotKV Cloud: all plans
- On-Premise: no license needed

`VSIM.SET` stores a vector under the name `key` in the vector index `index`,
replacing the key's previous vector if it had one. Give exactly as many
values as the index has dimensions.

`key` is just a name inside the index: it does not have to exist in the
keyspace, and deleting a keyspace key of the same name does not remove its
vector. Use the same name as the record it describes (for example the hash
holding a document) so search results point you to it. To filter searches by
tag, tag that keyspace key with [TAG.SET](https://docs.hotkv.com/commands/tag-set/index.md).

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| New key | Integer `1` | Integer `1` |
| Existing key, vector replaced | Integer `0` | Integer `0` |

Error replies:

- `ERR index 'name' not found`
- `ERR expected 3 dimensions, got 2` (with the index's and your counts).
- `ERR invalid float at dimension 1` for a value that is not a finite number (counting from 0).

## Examples

```
127.0.0.1:6379> VSIM.CREATEINDEX points 3 METRIC L2
OK
127.0.0.1:6379> VSIM.SET points p:1 1 0 0
(integer) 1
127.0.0.1:6379> VSIM.SET points p:1 1 0.5 0
(integer) 0
127.0.0.1:6379> VSIM.SET points p:2 1 1
(error) ERR expected 3 dimensions, got 2
127.0.0.1:6379> VSIM.SET points p:2 1 nan 0
(error) ERR invalid float at dimension 1
```

## Compatibility

HotKV-only command.

## See also

[VSIM.GET](https://docs.hotkv.com/commands/vsim-get/index.md), [VSIM.DEL](https://docs.hotkv.com/commands/vsim-del/index.md), [VSIM.SEARCH](https://docs.hotkv.com/commands/vsim-search/index.md),
[VSIM.CREATEINDEX](https://docs.hotkv.com/commands/vsim-createindex/index.md)