## Snippet 1

*qdrant-client* (vlatest) — https://qdrant.tech/course/beginners/module-2/ingestion-pipeline/

Ingests two documents into a Qdrant collection by computing 384-dim sentence embeddings with FastEmbed's TextEmbedding (model: sentence-transformers/all-MiniLM-L6-v2), building PointStruct entries with id, vector, and payload (title and category), and uploading them to the articles collection via client.upload_points (handles batching and retries). Uses the Qdrant client, PointStruct, and payload-based storage; the category is indexed as a KEYWORD field to enable fast, exact payload filtering. This enables semantic vector search combined with payload filtering (e.g., filtering results by automotive category during queries).

```python
!pip install fastembed

from qdrant_client.models import PointStruct
from fastembed import TextEmbedding

model = TextEmbedding(model_name="sentence-transformers/all-MiniLM-L6-v2")  # 384-dim

documents = [
    {"id": 1, "text": "Car repair guide",  "category": "automotive"},
    {"id": 2, "text": "How to cook pasta",  "category": "food"},
]

points = [
    PointStruct(
        id=doc["id"],
        vector=vector.tolist(),
        payload={"title": doc["text"], "category": doc["category"]},
    )
    for doc, vector in zip(documents, model.embed([d["text"] for d in documents]))
]
# upload_points handles batching and retries automatically; preferred for lists of points.
# upsert is the raw operation, better for single points or small real-time updates.
client.upload_points(collection_name="articles", points=points)

```

## Snippet 2

*qdrant-client* (vlatest) — https://qdrant.tech/documentation/tutorials-basics/search-beginners/

Uploads each book to the Qdrant my_books collection as a vector point: a unique id, a vector derived from the book description using the sentence-transformers/all-minilm-l6-v2 model, and a payload containing the book’s metadata. It builds PointStruct entries with models.Document (text and model) and uses client.upload_points to store both the embedding and the payload. This enables semantic search and retrieval of semantically similar books via client.query_points, returning hits with IDs, vectors, and metadata for downstream use.

```python
EMBEDDING_MODEL="sentence-transformers/all-minilm-l6-v2"

client.upload_points(
    collection_name=COLLECTION_NAME,
    points=[
        models.PointStruct(
            id=idx,
            vector=models.Document(
                text=doc["description"],
                model=EMBEDDING_MODEL
            ),
            payload=doc
        )
        for idx, doc in enumerate(documents)
    ],
)

```

## Snippet 3

*qdrant-client* (vlatest) — https://qdrant.tech/documentation/edge/edge-data-synchronization-patterns/

Background batch uploader that drains up to 10 PointStruct items from an upload_queue and bulk upserts them into a vector database collection. It uses a non-blocking drain (get_nowait) to accumulate a batch, catching Empty, then calls server_client.upsert(collection_name=COLLECTION_NAME, points=points_to_upload). This enables high-throughput ingestion of vector embeddings (id, vector, payload) into a server collection, suitable for vector search and embedding storage, with required error handling and retries for network or server outages.

```python
BATCH_SIZE = 10
points_to_upload: list[models.PointStruct] = []

while len(points_to_upload) < BATCH_SIZE:
    try:
        points_to_upload.append(upload_queue.get_nowait())
    except Empty:
        break

if points_to_upload:
    server_client.upsert(
        collection_name=COLLECTION_NAME, points=points_to_upload
    )

```
