📄Inserting Vectors in Cleartext
You can insert plaintext vectors in bulk using list[list[float]], list[np.ndarray], or a 2D numpy.ndarray.
If index_encryption=True in the index configuration, the vectors are always encrypted before insertion.
Important: Since
index_encryptionis always enabled, plaintext vectors are never stored or transmitted to the server. Only encrypted ciphertexts are sent and stored.
For detailed configuration, refer to Index Configuration.
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)
# vecs = [[0.001, 0.02, ..., 0.127]] # List[List[float]]
# vecs = [np.random.rand(512)] * 100 # List[np.ndarray]
# Normalize vectors before insertion (required for inner product metric)
vecs = vecs / np.linalg.norm(vecs, axis=1, keepdims=True)
index.insert(vecs)
# 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

