🏷️Inserting with Metadata
You can insert vectors together with metadata.
Metadata should be provided as a list of strings. If metadata_encryption=True is enabled in the index configuration, the metadata will be encrypted before being stored.
Note: When
metadata_encryption=True, metadata is also protected with end-to-end encryption. This means encryption happens on the client side and only clients with the secret key can decrypt it, ensuring that sensitive metadata is never exposed to the server.
Example
import numpy as np
import pyenvector as ev
ev.init(address="localhost:50050", key_path="keys", key_id="example")
index = ev.create_index("example_index", dim=512)
vecs = np.random.rand(100, 512)
# Normalize vectors for inner product metric
vecs = vecs / np.linalg.norm(vecs, axis=1, keepdims=True)
metadatas = [f"metadata_{i}" for i in range(100)]
index.insert(vecs, metadata=metadatas)
# Output:
# Index(
# IndexConfig(
# index_name="example_index",
# dim=512,
# key_path='keys',
# key_id='example',
# ),
# num_entities=100,
# cipher=<pyenvector.crypto.cipher.Cipher object at 0x7f1776199d60>
#)Last updated

