is_trained

Returns True if the index has been trained, enabling efficient approximate nearest neighbor search. An untrained index will default to exhaustive search.
def is_trained(self) -> bool

Returns

bool: True if the index has been trained; otherwise, False.

Example Usage

# Check if index is trained
if index.is_trained():
    print("The index is ready for efficient querying.")
else:
    print("The index is not trained; consider calling train().")

index_name

Retrieves the name of the current index.
def index_name(self) -> str

Returns

str: Name of the currently loaded or created index.

Example Usage

# Retrieve the index name
print("Current index name:", index.index_name())

index_type

Returns the type of the current index (e.g., ivf, ivfpq, ivfflat).
def index_type(self) -> str

Returns

Return TypeDescription
strType of the current index.

Example Usage

# Retrieve the type of index
print("Index type:", index.index_type())

index_config

Retrieves the configuration details of the current index.
def index_config(self) -> dict

Returns

dict: A dictionary containing the configuration of the index with the following keys:
  • dimension: The dimensionality of the vectors
  • metric: The distance metric used (e.g., ‘euclidean’, ‘cosine’)
  • index_type: The type of the index (e.g., ‘ivf’, ‘ivfpq’, ‘ivfflat’)
  • n_lists: The number of inverted lists in the index
  • pq_dim: The PQ dimension (if applicable)
  • pq_bits: The PQ bits (if applicable)

Example Usage

# Retrieve index config
config = index.index_config()
print(f"Dimension: {config['dimension']}")
print(f"Metric: {config['metric']}")
print(f"Index type: {config['index_type']}")

get_num_vectors

Returns the number of vectors currently stored in the index.
def get_num_vectors(self) -> int

Returns

int: The number of vectors in the index.

Example Usage

# Get the number of vectors in the index
num_vectors = index.get_num_vectors()
print(f"The index contains {num_vectors} vectors.")

list_ids

Lists all item IDs currently stored in the index.
def list_ids(self) -> List[str]

Returns

List[str]: A list containing all item IDs in the index.

Exceptions

Example Usage

# List all IDs in the index
all_ids = index.list_ids()
print(f"Total items in index: {len(all_ids)}")

# Print first 10 IDs
for id in all_ids[:10]:
    print(f"ID: {id}")