Skip to main content

MeiliSearch API 的 python 异步客户端。

项目描述

ameiliSearch

100%兼容MeiliSearch Python的异步MeiliSearch API客户端

上游提交哈希:e665923efc9735fd09994b0f01395ceb29051c71

入门

添加文件

import asyncio
import ameilisearch


async def main():
    documents = [
        { 'id': 1, 'title': 'Carol', 'genres': ['Romance', 'Drama'] },
        { 'id': 2, 'title': 'Wonder Woman', 'genres': ['Action', 'Adventure'] },
        { 'id': 3, 'title': 'Life of Pi', 'genres': ['Adventure', 'Drama'] },
        { 'id': 4, 'title': 'Mad Max: Fury Road', 'genres': ['Adventure', 'Science Fiction'] },
        { 'id': 5, 'title': 'Moana', 'genres': ['Fantasy', 'Action']},
        { 'id': 6, 'title': 'Philadelphia', 'genres': ['Drama'] },
    ]

    async with ameilisearch.Client("http://127.0.0.1:7700", 'masterKey') as client:
        async with client.index("movies") as index:
            # If the index 'movies' does not exist, MeiliSearch creates it when you first add the documents.
            await index.add_documents(documents) # => { "updateId": 0 }

asyncio.get_event_loop().run_until_complete(main())

与同步客户端的区别

现有的 API 客户端使用requests.

ameilisearch 与aiohttp.

用户需要管理客户端会话。

http 实例位于两个地方:ClientIndex.

使用async with语法在使用后立即关闭会话,或者必须在使用await :client_or_index_instance:.http.session.close()后关闭会话。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

ameilisearch-0.3.4.tar.gz (13.8 kB 查看哈希)

已上传 source

内置分布

ameilisearch-0.3.4-py3-none-any.whl (16.5 kB 查看哈希

已上传 py3