Meilisearch Python Client

raw JSON →
0.40.0 verified Tue May 12 auth: no python install: verified quickstart: stale

Official Python client for Meilisearch — open source typo-tolerant search engine. Current version: 0.40.0 (Jan 2026). Still pre-1.0. Official 'meilisearch' package is SYNC ONLY. For async use the community 'meilisearch-python-sdk' package instead. Two different packages, two different imports. add_documents() is non-blocking — returns a Task object, not a confirmation. Must poll task status to confirm indexing completed. Compatible with Meilisearch server v1.2+.

pip install meilisearch
error ModuleNotFoundError: No module named 'meilisearch'
cause The 'meilisearch' package is not installed in the Python environment, or there is a typo in the import statement, or the wrong package name is used (e.g., trying to import 'meilisearch' when 'meilisearch-python-sdk' was intended and installed).
fix
Ensure the correct package is installed using pip install meilisearch for the sync client, or pip install meilisearch-python-sdk for the async client. Then, verify the import statement, e.g., import meilisearch or from meilisearch_python_sdk import Client as AsyncClient.
error meilisearch.errors.MeilisearchCommunicationError
cause The Python client failed to establish a connection with the Meilisearch server. This often happens if the server is not running, is running on a different URL or port than specified, or a firewall is blocking the connection. This can also manifest as `ConnectionError: Max retries exceeded` or `Connection refused` messages from the underlying requests library.
fix
Verify that your Meilisearch server instance is running and accessible at the specified URL and port (default is http://localhost:7700). Ensure the URL includes http:// or https://. Example: client = meilisearch.Client('http://127.0.0.1:7700', 'YOUR_MASTER_KEY').
error MeilisearchApiError: Error code: invalid_document_uid. Error message: A document must have a 'id' field with a string or integer value.
cause When adding documents to a Meilisearch index, each document must contain a unique primary key. By default, Meilisearch looks for a field named 'id' (case-insensitive) to use as the primary key. If no 'id' field is present and a `primary_key` is not explicitly set for the index, this error occurs.
fix
Ensure each document in your list has a unique 'id' field (or the field specified as primary_key when the index was created or updated). If 'id' is not desired, set a different primary_key when creating the index: client.create_index('my_index', {'primaryKey': 'my_custom_id'}).
error TypeError: object NoneType can't be awaited
cause This error typically occurs when trying to use `await` with the synchronous `meilisearch` client's methods. The official `meilisearch` package is synchronous only. Asynchronous operations require the `meilisearch-python-sdk` package and its `AsyncClient`.
fix
If you intend to use asynchronous operations, install meilisearch-python-sdk (pip install meilisearch-python-sdk) and import AsyncClient: from meilisearch_python_sdk import AsyncClient. If you are using the meilisearch package, remove await keywords as its methods are blocking.
breaking Official 'meilisearch' package is sync-only. No async support. For FastAPI/asyncio use 'meilisearch-python-sdk' (community package) which provides AsyncClient.
fix pip install meilisearch-python-sdk; from meilisearch_python_sdk import AsyncClient
gotcha add_documents() is non-blocking — returns a Task object with task_uid. Documents are NOT immediately searchable. Searching immediately after add_documents may return empty results.
fix Call client.wait_for_task(task.task_uid) after indexing to wait for completion. In production use task polling instead.
gotcha Updating filterableAttributes or sortableAttributes triggers a full index rebuild. On large datasets this can take minutes. Index is still searchable during rebuild but with old settings.
fix Set filterableAttributes and sortableAttributes once at index creation time. Track the returned task and wait before querying with new filters.
gotcha Every document must have a primary key field. Default is 'id'. If no 'id' field exists and no primary key is specified, indexing fails silently or raises MeilisearchApiError.
fix Always include 'id' field in documents, or specify primary_key when creating index: client.create_index('movies', {'primaryKey': 'movie_id'})
gotcha client.index('name') does NOT create the index — it returns an index reference object. Index is created on first add_documents() call or explicitly with client.create_index().
fix Use client.get_index('name') to get an existing index (raises if not found). Use client.index('name') as a reference that auto-creates on first write.
gotcha Still pre-1.0 (0.40.x). API may change across minor versions. Compatible with Meilisearch server v1.2+ only.
fix Pin version: pip install meilisearch==0.40.0. Check server compatibility at github.com/meilisearch/meilisearch-python.
breaking Meilisearch client failed to connect to the server (Connection refused). This typically means the Meilisearch server is not running or is not accessible at the specified host and port (default 127.0.0.1:7700).
fix Ensure the Meilisearch server is running and accessible. If it's on a different host or port, initialize the client with `Client('http://your-meilisearch-host:port', 'your-master-key')`.
breaking Failed to connect to Meilisearch server. A ConnectionRefusedError typically means the Meilisearch server process is not running, or it's not accessible at the configured host and port (default 127.0.0.1:7700).
fix Ensure the Meilisearch server is running and accessible before initializing the client or making API calls. Check the server's listening address and port, and configure your Meilisearch client accordingly if it differs from the default.
pip install meilisearch-python-sdk
python os / libc variant status wheel install import disk
3.10 alpine (musl) meilisearch - - 0.99s 31.6M
3.10 alpine (musl) meilisearch-python-sdk - - - -
3.10 slim (glibc) meilisearch - - 0.71s 31M
3.10 slim (glibc) meilisearch-python-sdk - - - -
3.11 alpine (musl) meilisearch - - 1.35s 34.5M
3.11 alpine (musl) meilisearch-python-sdk - - - -
3.11 slim (glibc) meilisearch - - 1.11s 34M
3.11 slim (glibc) meilisearch-python-sdk - - - -
3.12 alpine (musl) meilisearch - - 1.46s 26.1M
3.12 alpine (musl) meilisearch-python-sdk - - - -
3.12 slim (glibc) meilisearch - - 1.46s 26M
3.12 slim (glibc) meilisearch-python-sdk - - - -
3.13 alpine (musl) meilisearch - - 1.03s 25.8M
3.13 alpine (musl) meilisearch-python-sdk - - - -
3.13 slim (glibc) meilisearch - - 1.04s 25M
3.13 slim (glibc) meilisearch-python-sdk - - - -
3.9 alpine (musl) meilisearch - - 0.94s 31.0M
3.9 alpine (musl) meilisearch-python-sdk - - - -
3.9 slim (glibc) meilisearch - - 0.85s 31M
3.9 slim (glibc) meilisearch-python-sdk - - - -

Meilisearch Python client — indexing, waiting for task, and search.

# pip install meilisearch
import meilisearch
import time

client = meilisearch.Client('http://127.0.0.1:7700', 'masterKey')
index = client.index('products')

# Add documents (non-blocking)
task = index.add_documents([
    {'id': '1', 'name': 'Widget', 'price': 9.99},
    {'id': '2', 'name': 'Gadget', 'price': 24.99},
])

# Wait for indexing (dev only — use task polling in production)
client.wait_for_task(task.task_uid)

# Configure filterable attributes (triggers re-index)
index.update_filterable_attributes(['price'])

# Search
result = index.search('widget')
for hit in result['hits']:
    print(hit['name'])

# Search with filter
result = index.search('', {'filter': 'price < 15'})
print(result['hits'])