Skip to main content

Async library for MeiliSearch

Project description

Tests pypi versions

AIO_MEILISEARCH

Async Wrapper over Meilisearch REST API with type hints

pip install aio_meilisearch

Usage

from typing import TypedDict, List, Optional
import httpx
from aio_meilisearch import (
    MeiliSearch,
    MeiliConfig,
    Index,
    SearchResponse,
)


class MovieDict(TypedDict):
    id: str
    name: str
    genres: List[str]
    url: str
    year: int


http = httpx.AsyncClient()

meilisearch = MeiliSearch(
    meili_config=MeiliConfig(
        base_url='http://localhost:7700',
        private_key='PRIVATE_KEY',
        public_key='PUBLIC_KEY',
    ),
    http_client=http,
)


index: Index[MovieDict] = await meilisearch.create_index(name="movies", pk="id")

await index.update_settings(
    {
        "searchableAttributes": ["name", "genres"],
        "displayedAttributes": [
            "name",
            "genres",
            "id",
            "url",
            "year",
        ],
        "attributesForFaceting": ["genres", "year"],
    }
)

movie_list: List[MovieDict] = [
    {
        "name": "Oblivion",
        "genres": ["action", "adventure", "sci-fi"],
        "id": "tt1483013",
        "url": "https://www.imdb.com/title/tt1483013/",
        "year": 2013,
    }
]

await index.documents.add_many(movie_list)

response: SearchResponse[MovieDict] = await index.documents.search(query="action")

Contributing

Prerequisites:

  • poetry
  • nox
  • nox-poetry

Install them on your system:

pip install poetry nox nox-poetry

Run tests:

nox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aio-meilisearch, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size aio_meilisearch-0.1.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View
Filename, size aio_meilisearch-0.1.1-py3-none-any.whl (6.8 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page