Aurelio Docs
Client Referenceindex

semantic_router.index.qdrant

QdrantIndex Objects

class QdrantIndex(BaseIndex)

The name of the collection to use

add

def add(embeddings: List[List[float]],
        routes: List[str],
        utterances: List[Any],
        metadata_list: Optional[List[Dict[str, Any]]] = None,
        sparse_embeddings: Optional[List[SparseEmbedding]] = None,
        batch_size: int = DEFAULT_UPLOAD_BATCH_SIZE,
        **kwargs)

Upsert records into the index, one point per (route, utterance) pair.

Arguments:

  • embeddings (List[List[float]]): The embeddings to add.
  • routes (List[str]): The routes to add.
  • utterances (List[str]): The utterances to add.
  • metadata_list (Optional[List[Dict[str, Any]]]): The metadata to add.
  • sparse_embeddings (Optional[List[SparseEmbedding]]): Not supported, QdrantIndex is dense only.
  • List[List[float]]0 (List[List[float]]1): The batch size to use for the upload.

delete

def delete(route_name: str)

Delete records from the index.

Arguments:

  • route_name (str): The name of the route to delete.

describe

def describe() -> IndexConfig

Describe the index.

Returns:

IndexConfig: The index configuration.

is_ready

def is_ready() -> bool

Checks if the index is ready to be used.

Returns:

bool: True if the index is ready, False otherwise.

query

def query(
    vector: np.ndarray,
    top_k: int = 5,
    route_filter: Optional[List[str]] = None,
    sparse_vector: dict[int, float] | SparseEmbedding | None = None,
    return_utterances: bool = False
) -> Tuple[np.ndarray, List[str]] | Tuple[np.ndarray, List[str], List[str]]

Query the index.

Arguments:

  • vector (np.ndarray): The vector to query.
  • top_k (int): The number of results to return.
  • route_filter (Optional[List[str]]): The route filter to apply.
  • sparse_vector (dict[int, float] | SparseEmbedding | None): The sparse vector to query.
  • return_utterances (bool): If True, also return the matched utterance texts.

Returns:

np.ndarray0: np.ndarray1(scores, route_names)np.ndarray1 by default, or np.ndarray1(scores, route_names, utterances)np.ndarray1 when np.ndarray1return_utterances=Truenp.ndarray1.

aquery

async def aquery(
    vector: np.ndarray,
    top_k: int = 5,
    route_filter: Optional[List[str]] = None,
    sparse_vector: dict[int, float] | SparseEmbedding | None = None,
    return_utterances: bool = False
) -> Tuple[np.ndarray, List[str]] | Tuple[np.ndarray, List[str], List[str]]

Asynchronously query the index.

Arguments:

  • vector (np.ndarray): The vector to query.
  • top_k (int): The number of results to return.
  • route_filter (Optional[List[str]]): The route filter to apply.
  • sparse_vector (dict[int, float] | SparseEmbedding | None): The sparse vector to query.
  • return_utterances (bool): If True, also return the matched utterance texts.

Returns:

np.ndarray0: np.ndarray1(scores, route_names)np.ndarray1 by default, or np.ndarray1(scores, route_names, utterances)np.ndarray1 when np.ndarray1return_utterances=Truenp.ndarray1.

delete_index

def delete_index()

Delete the index.

Returns:

None: None

convert_metric

def convert_metric(metric: Metric)

Convert the metric to a Qdrant distance metric.

Arguments:

  • metric (Metric): The metric to convert.

Returns:

Distance: The converted metric.

__len__

def __len__()

Returns the total number of vectors in the index. If the index is not initialized

returns 0.

Returns:

int: The total number of vectors.

adelete

async def adelete(route_name: str) -> list[str]

Asynchronously delete records from the index by route name.

Arguments:

  • route_name (str): The name of the route to delete.

Returns:

list[str]: List of IDs of the vectors deleted (empty list, as Qdrant does not return IDs).

adelete_index

async def adelete_index()

Asynchronously delete the index (collection) from Qdrant.

Returns:

None: None

ais_ready

async def ais_ready() -> bool

Checks if the index is ready to be used asynchronously.

aadd

async def aadd(embeddings: List[List[float]],
               routes: List[str],
               utterances: List[Any],
               metadata_list: Optional[List[Dict[str, Any]]] = None,
               sparse_embeddings: Optional[List[SparseEmbedding]] = None,
               batch_size: int = DEFAULT_UPLOAD_BATCH_SIZE,
               **kwargs)

Asynchronously upsert records into the index, one point per (route, utterance) pair.

On this page