Search Toolkit
Search Toolkit is a Python framework for building information retrieval (IR) systems. It provides components for ingestion, retrieval, and evaluation. It works across backends, and every component can be swapped.
LLMs aren't trained on your private data. To ground their answers in your documents, you need a retrieval pipeline that ingests, indexes, and searches your content. Search Toolkit provides the building blocks for that pipeline.
Key features
Ingestion
Ingestion includes:
- Multi-format extraction: PDF, DOCX, and PPTX through Mistral OCR, HTML, spreadsheets, emails, plain text
- File loading: Load from the local filesystem, S3, Google Cloud Storage, or Azure Blob Storage, or implement custom loaders for any source
- Flexible chunking: Character, token, markdown-aware, or separator-based splitting
- Enrichment: Enrich documents and chunks with custom metadata or LLM-generated summaries
- Indexing: Index into a Mistral Search Index
Retrieval
Retrieval includes:
- Search: Vector or hybrid search on the index in one call
- Custom retrieval: With
retrieve, combine vector and keyword retrievers, match custom fields, and weight the fusion - Filters: Narrow
retrieveresults by category, date, source, or any custom field
Architecture
Ingestion transforms raw documents into searchable chunks. A FileLoader reads raw bytes from a source, a DocumentExtractor converts them into a structured document, a TextSplitter divides it into chunks, optional DocumentProcessor stages (such as a ChunkEnricher or SummaryEnricher) add metadata, and an Embedder produces vectors for indexing into a Mistral Search Index.
Retrieval finds relevant chunks for a given query. The search index runs the query through one of two methods: search for a vector or hybrid search, or retrieve for a retrieval query that you compose yourself, with filters.
Pipeline orchestrates ingestion. You can swap every ingestion component: use the built-in implementations or bring your own.
Components
| Component | Built-in options |
|---|---|
| File loaders | FilesystemFileLoader, S3FileLoader, GCSFileLoader, AzureBlobFileLoader, custom loaders |
| Extractors | MistralOCRExtractor, SmartPDFExtractor, PlainTextExtractor, PyMuPDFExtractor, HTMLExtractor, SpreadsheetExtractor, EmailExtractor, EmailWithAttachmentsExtractor, NumbersExtractor, LegacyOfficeExtractor, MistralAudioTranscriptionExtractor |
| Text splitters | CharacterTextSplitter, TokenTextSplitter, MarkdownTextSplitter, ParagraphTokenTextSplitter, MarkdownTokenTextSplitter, SeparatorTextSplitter |
| Enrichers | SummaryEnricher, custom ChunkEnricher |
| Embedders | MistralEmbedder, custom Embedder |
| Storage | Mistral Search Index, Vespa, Postgres (pgvector), Qdrant, or custom vector store |
| Retrieval | search and retrieve on the index, with filters on retrieve |
Installation and extras
Install the core package:
uv add mistralai-search-toolkitThe core package includes the Mistral Search Index backend, the default storage for Search Toolkit pipelines. Self-hosted backends such as Vespa and Postgres ship as extras.
Optional extras add specialized functionality:
| Extra | Description |
|---|---|
vespa | Vespa plugin for vector storage and semantic search |
postgres | PostgreSQL backend with pgvector and pg_textsearch |
extractor-pymupdf | Advanced PDF extraction with PyMuPDF Pro |
extractor-spreadsheet | Spreadsheet parsing (Excel, CSV, Apple Numbers) |
extractor-email | Email file parsing (EML, MSG formats) |
html-converter-markdownify | Convert HTML to Markdown |
text-splitter-langchain | Additional text splitting strategies via LangChain |
storage-gcs | Google Cloud Storage integration |
storage-azure | Azure Blob Storage integration |
storage-s3 | Amazon S3 integration |
Install extras with the core package:
uv add "mistralai-search-toolkit[extractor-pymupdf]"
uv add "mistralai-search-toolkit[extractor-pymupdf,storage-s3]"All packages are available on PyPI.
Requires Python 3.12 to 3.14. We recommend uv for dependency management.
Conventions
- Everything is async. Await every index, service, and pipeline call, and run them inside an
asyncfunction or withasyncio.run. - Models are immutable.
Document,DocumentChunk, their metadata, andSearchResultare frozen Pydantic models. To change one, create a copy withmodel_copy(update={...}). - Pass request context in a context object. Every ingestion and retrieval call takes an optional
IngestContextorRetrievalContext. To pass tenant IDs, tracing spans, or per-request Mistral API headers through the stack without adding arguments, subclass these context classes.
Check your setup
Before you build on a new index, check it end to end:
- Check that
(await service.get_index_info(name)).statusisready. - Ingest one document.
- Check that a
searchorretrievefor a phrase from that document returns the document.
The Quickstart runs these three steps.
Next steps
- Quickstart: build your first ingestion and retrieval pipeline end to end.
- Document model: understand
Document,DocumentChunk, and the identity that ties them together. - Embedding model: understand how the schema describes embedding vectors, separately from the embedder.
- Search index: set up your vector store.
- Ingestion: load, extract, chunk, enrich, and index your documents.
- Retrieval: query the index with
searchandretrieve.