The python async client for MeiliSearch API.
Project description
ameiliSearch
Asynchronous MeiliSearch API client that is 100% compatible with MeiliSearch Python
upstream commit hash: e665923efc9735fd09994b0f01395ceb29051c71
Getting Started
Add Documents
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())
Differences from synchronous clients
Existing API clients worked with requests
.
ameilisearch works with aiohttp
.
Users need to manage client sessions.
The http instance is in two places: Client
and Index
.
Use the async with
syntax to close the session immediately after use, or must close the session using await :client_or_index_instance:.http.session.close()
after using it all.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ameilisearch-0.3.1.tar.gz
(13.7 kB
view hashes)
Built Distribution
Close
Hashes for ameilisearch-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c06ea5034c0145473f2a46dcf72239a60da342a3b098c870fc5ab8bd79505219 |
|
MD5 | fa532b9a4966a5cea73c7cd6681dae9d |
|
BLAKE2b-256 | d46344d6ef0d046246aac4750fbb907f2346368a4a4656068d2202ecb62c05e1 |