CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-qdrant-client

Client library for the Qdrant vector search engine

Pending
Overview
Eval results
Files

vector-operations.mddocs/

Vector Operations

Point insertion, updating, deletion, and retrieval operations including batch processing and bulk upload utilities.

Capabilities

Point Insertion and Updates

Insert or update individual points and batches of points.

def upsert(
    self,
    collection_name: str,
    points: Iterable[PointStruct],
    wait: bool = True,
    ordering: Optional[WriteOrdering] = None,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> UpdateResult:
    """
    Insert or update points in collection.

    Parameters:
    - collection_name: Name of the collection
    - points: Iterable of points to upsert
    - wait: Wait for operation to complete
    - ordering: Write ordering guarantees
    - shard_key_selector: Shard key for routing

    Returns:
        UpdateResult: Result of the operation
    """

def upload_points(
    self,
    collection_name: str,
    points: Iterable[PointStruct],
    batch_size: int = 100,
    parallel: int = 1,
    max_retries: int = 3,
    wait: bool = True,
    shard_key_selector: Optional[ShardKeySelector] = None,
) -> None:
    """
    Upload points in batches with automatic retry.

    Parameters:
    - collection_name: Name of the collection
    - points: Iterable of points to upload
    - batch_size: Number of points per batch
    - parallel: Number of parallel upload threads
    - max_retries: Maximum retry attempts
    - wait: Wait for operation to complete
    - shard_key_selector: Shard key for routing
    """

def batch_update_points(
    self,
    collection_name: str,
    update_operations: List[PointsUpdateOperation],
    wait: bool = True,
    ordering: Optional[WriteOrdering] = None,
    **kwargs
) -> List[UpdateResult]:
    """
    Perform batch update of points.

    Parameters:
    - collection_name: Name of the collection
    - update_operations: List of update operations
    - wait: Wait for operation to complete
    - ordering: Write ordering guarantees

    Returns:
        List[UpdateResult]: Results of operations
    """

Usage examples:

import numpy as np
from qdrant_client import models

# Single point upsert
point = models.PointStruct(
    id=1,
    vector=np.random.rand(100).tolist(),
    payload={"category": "test", "value": 42}
)
client.upsert(collection_name="test_collection", points=[point])

# Batch upsert
points = [
    models.PointStruct(
        id=i,
        vector=np.random.rand(100).tolist(),
        payload={"index": i, "category": f"cat_{i % 5}"}
    )
    for i in range(1000)
]
client.upsert(collection_name="test_collection", points=points)

# Large-scale upload with batching
client.upload_points(
    collection_name="test_collection",
    points=points,
    batch_size=50,
    parallel=4
)

Point Retrieval

Retrieve points by ID or scroll through all points.

def retrieve(
    self,
    collection_name: str,
    ids: List[PointId],
    with_payload: Union[bool, List[str], PayloadSelector] = True,
    with_vectors: Union[bool, List[str]] = False,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> List[Record]:
    """
    Retrieve points by their IDs.

    Parameters:
    - collection_name: Name of the collection
    - ids: List of point IDs to retrieve
    - with_payload: Include payload in response
    - with_vectors: Include vectors in response
    - shard_key_selector: Shard key for routing

    Returns:
        List[Record]: Retrieved points
    """

def scroll(
    self,
    collection_name: str,
    scroll_filter: Optional[Filter] = None,
    limit: Optional[int] = None,
    offset: Optional[PointId] = None,
    with_payload: Union[bool, List[str], PayloadSelector] = True,
    with_vectors: Union[bool, List[str]] = False,
    order_by: Optional[OrderBy] = None,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> Tuple[List[Record], Optional[PointId]]:
    """
    Scroll through points in collection.

    Parameters:
    - collection_name: Name of the collection
    - scroll_filter: Filter for points to scroll through
    - limit: Maximum number of points to return
    - offset: Starting point ID for pagination
    - with_payload: Include payload in response
    - with_vectors: Include vectors in response
    - order_by: Sort order for results
    - shard_key_selector: Shard key for routing

    Returns:
        Tuple[List[Record], Optional[PointId]]: Points and next offset
    """

Point Deletion

Delete points by ID or filter criteria.

def delete(
    self,
    collection_name: str,
    points_selector: Union[PointIdsList, FilterSelector],
    wait: bool = True,
    ordering: Optional[WriteOrdering] = None,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> UpdateResult:
    """
    Delete points from collection.

    Parameters:
    - collection_name: Name of the collection
    - points_selector: Points to delete (by ID or filter)
    - wait: Wait for operation to complete
    - ordering: Write ordering guarantees
    - shard_key_selector: Shard key for routing

    Returns:
        UpdateResult: Result of the operation
    """

Usage examples:

# Delete by IDs
client.delete(
    collection_name="test_collection",
    points_selector=models.PointIdsList(points=[1, 2, 3, 4])
)

# Delete by filter
client.delete(
    collection_name="test_collection",
    points_selector=models.FilterSelector(
        filter=models.Filter(
            must=[
                models.FieldCondition(
                    key="category",
                    match=models.MatchValue(value="outdated")
                )
            ]
        )
    )
)

Payload Operations

Update and delete payload fields without affecting vectors.

def set_payload(
    self,
    collection_name: str,
    payload: Payload,
    points: Union[List[PointId], Filter, None] = None,
    wait: bool = True,
    ordering: Optional[WriteOrdering] = None,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> UpdateResult:
    """
    Set payload for specified points.

    Parameters:
    - collection_name: Name of the collection
    - payload: Payload to set
    - points: Points to update (IDs or filter)
    - wait: Wait for operation to complete
    - ordering: Write ordering guarantees
    - shard_key_selector: Shard key for routing

    Returns:
        UpdateResult: Result of the operation
    """

def overwrite_payload(
    self,
    collection_name: str,
    payload: Payload,
    points: Union[List[PointId], Filter, None] = None,
    wait: bool = True,
    ordering: Optional[WriteOrdering] = None,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> UpdateResult:
    """
    Overwrite payload for specified points.

    Parameters:
    - collection_name: Name of the collection
    - payload: New payload (replaces existing)
    - points: Points to update (IDs or filter)
    - wait: Wait for operation to complete
    - ordering: Write ordering guarantees
    - shard_key_selector: Shard key for routing

    Returns:
        UpdateResult: Result of the operation
    """

def delete_payload(
    self,
    collection_name: str,
    keys: List[str],
    points: Union[List[PointId], Filter, None] = None,
    wait: bool = True,
    ordering: Optional[WriteOrdering] = None,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> UpdateResult:
    """
    Delete payload keys from specified points.

    Parameters:
    - collection_name: Name of the collection
    - keys: Payload keys to delete
    - points: Points to update (IDs or filter)
    - wait: Wait for operation to complete
    - ordering: Write ordering guarantees
    - shard_key_selector: Shard key for routing

    Returns:
        UpdateResult: Result of the operation
    """

def clear_payload(
    self,
    collection_name: str,
    points_selector: Union[PointIdsList, FilterSelector],
    wait: bool = True,
    ordering: Optional[WriteOrdering] = None,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> UpdateResult:
    """
    Clear all payload from specified points.

    Parameters:
    - collection_name: Name of the collection
    - points_selector: Points to clear (by ID or filter)
    - wait: Wait for operation to complete
    - ordering: Write ordering guarantees
    - shard_key_selector: Shard key for routing

    Returns:
        UpdateResult: Result of the operation
    """

Point Counting

Count points in collection with optional filtering.

def count(
    self,
    collection_name: str,
    count_filter: Optional[Filter] = None,
    exact: bool = True,
    shard_key_selector: Optional[ShardKeySelector] = None,
    **kwargs
) -> CountResult:
    """
    Count points in collection.

    Parameters:
    - collection_name: Name of the collection
    - count_filter: Filter for points to count
    - exact: Whether to return exact count
    - shard_key_selector: Shard key for routing

    Returns:
        CountResult: Point count
    """

Data Types

Point Structures

class PointStruct(BaseModel):
    id: PointId  # Point identifier
    vector: Union[VectorStruct, Dict[str, VectorStruct]]  # Vector data
    payload: Optional[Payload] = None  # Associated metadata

class Record(BaseModel):
    id: PointId
    payload: Optional[Payload] = None
    vector: Optional[Union[VectorStruct, Dict[str, VectorStruct]]] = None
    shard_key: Optional[ShardKey] = None

# Type aliases
PointId = Union[str, int]
VectorStruct = List[float]
Payload = Dict[str, Any]

Selection and Filtering

class PointIdsList(BaseModel):
    points: List[PointId]

class FilterSelector(BaseModel):
    filter: Filter

class PayloadSelector(BaseModel):
    include: Optional[List[str]] = None  # Include specific payload keys
    exclude: Optional[List[str]] = None  # Exclude specific payload keys

Update Operations

class UpdateResult(BaseModel):
    operation_id: Optional[int] = None
    status: UpdateStatus

class UpdateStatus(str, Enum):
    ACKNOWLEDGED = "acknowledged"
    COMPLETED = "completed"

class WriteOrdering(str, Enum):
    WEAK = "weak"      # No ordering guarantees
    MEDIUM = "medium"  # Updates applied in order
    STRONG = "strong"  # Consistent ordering across all operations

class CountResult(BaseModel):
    count: int

Batch Operations

class PointsUpdateOperation(BaseModel):
    upsert: Optional[PointsList] = None
    delete: Optional[PointsSelector] = None
    set_payload: Optional[SetPayload] = None
    overwrite_payload: Optional[SetPayload] = None
    delete_payload: Optional[DeletePayload] = None
    clear_payload: Optional[PointsSelector] = None

class PointsList(BaseModel):
    points: List[PointStruct]
    shard_key: Optional[ShardKey] = None

class PointsSelector(BaseModel):
    points: Union[PointIdsList, FilterSelector]
    shard_key: Optional[ShardKey] = None

Install with Tessl CLI

npx tessl i tessl/pypi-qdrant-client

docs

client-setup.md

clustering-sharding.md

collection-management.md

fastembed-integration.md

index.md

indexing-optimization.md

search-query.md

snapshots-backup.md

vector-operations.md

tile.json