1. 📇 Name and Dimension

Index name and dimension are the two required basics for any index. Together they give the index its unique identity (name) and shape (vector dimension).

Recommendation: Although you can set defaults via init_index_config(), it’s clearer and safer to pass index_name and dim explicitly to create_index(). This makes it easy to create multiple distinct indexes from a single client instance.


Parameters (required)

  • index_name (str): Unique identifier for the index. Used in all subsequent operations (insert, search, drop, etc.).

  • dim (int): Vector dimension for this index. Every vector you insert must match this value. For example, OpenAI’s text-embedding-ada-002 uses 1536.

Why these two?

  • Identity: index_name is the stable handle you use to address the index on the server.

  • Shape: dim locks the index to a single embedding size and protects against accidental inserts with the wrong length.

Usage Example

The snippet below shows the recommended way to pass these parameters to create_index() (after you’ve connected and optionally initialized index configuration).

import pyenvector as ev

# Assume the client has already been initialized with ev.init()

# Create a new index named 'product-vectors' for 768-dimensional vectors
ev.create_index(index_name="product-vectors", dim=768)

# You can now create another, separate index with a different name and dimension
ev.create_index(index_name="image-embeddings", dim=1024)

Last updated