AsyncClient
AsyncClient
Usage
Create a client with a context manager
This client runs in a context manager which ensures that everything is cleaned up after the use of the client is done. To create a client:
from meilisearch-python-sdk import AsyncClient
async with AsyncClient("http://localhost:7700", "masterKey") as client:
index = client.index("movies")
...
Custom headers
Custom headers can be added to the client by adding them to custom_headers
when creating the
client.
from meilisearch_python_sdk import AsyncClient
async with AsyncClient(
"http://127.0.0.1:7700",
"masterKey",
custom_headers={"header_key_1": "header_value_1", "header_key_2": "header_value_2"}
) as client:
index = client.index("movies")
...
Create a client without a context manager
It is also possible to call the client without using a context manager, but in doing so you will need to make sure to do the cleanup yourself:
from meilisearch-python-sdk import AsyncClient
try:
client = AsyncClient("http://localhost:7700", "masterKey")
...
finally:
await client.aclose()
AsyncClient
API
Bases: BaseClient
Async client to connect to the Meilisearch API.
Source code in meilisearch_python_sdk/_client.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 |
|
__init__(url, api_key=None, *, timeout=None, verify=True, custom_headers=None, json_handler=None, http2=False)
Class initializer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The url to the Meilisearch API (ex: http://localhost:7700) |
required |
api_key
|
str | None
|
The optional API key for Meilisearch. Defaults to None. |
None
|
timeout
|
int | None
|
The amount of time in seconds that the client will wait for a response before timing out. Defaults to None. |
None
|
verify
|
bool | SSLContext
|
SSL certificates (a.k.a CA bundle) used to
verify the identity of requested hosts. Either |
True
|
custom_headers
|
dict[str, str] | None
|
Custom headers to add when sending data to Meilisearch. Defaults to None. |
None
|
json_handler
|
BuiltinHandler | OrjsonHandler | UjsonHandler | None
|
The module to use for json operations. The options are BuiltinHandler (uses the json module from the standard library), OrjsonHandler (uses orjson), or UjsonHandler (uses ujson). Note that in order use orjson or ujson the corresponding extra needs to be included. Default: BuiltinHandler. |
None
|
http2
|
bool
|
Whether or not to use HTTP/2. Defaults to False. |
False
|
Source code in meilisearch_python_sdk/_client.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
aclose()
async
Closes the client.
This only needs to be used if the client was not created with a context manager.
Source code in meilisearch_python_sdk/_client.py
190 191 192 193 194 195 |
|
cancel_tasks(*, uids=None, index_uids=None, statuses=None, types=None, before_enqueued_at=None, after_enqueued_at=None, before_started_at=None, after_finished_at=None)
async
Cancel a list of enqueued or processing tasks.
Defaults to cancelling all tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uids
|
list[str] | None
|
A list of task UIDs to cancel. |
None
|
index_uids
|
list[str] | None
|
A list of index UIDs for which to cancel tasks. |
None
|
statuses
|
list[str] | None
|
A list of statuses to cancel. |
None
|
types
|
list[str] | None
|
A list of types to cancel. |
None
|
before_enqueued_at
|
datetime | None
|
Cancel tasks that were enqueued before the specified date time. |
None
|
after_enqueued_at
|
datetime | None
|
Cancel tasks that were enqueued after the specified date time. |
None
|
before_started_at
|
datetime | None
|
Cancel tasks that were started before the specified date time. |
None
|
after_finished_at
|
datetime | None
|
Cancel tasks that were finished after the specified date time. |
None
|
Returns:
Type | Description |
---|---|
TaskInfo
|
The details of the task |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
MeilisearchTimeoutError
|
If the connection times out. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> await client.cancel_tasks(uids=[1, 2])
Source code in meilisearch_python_sdk/_client.py
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 |
|
create_dump()
async
Trigger the creation of a Meilisearch dump.
Returns:
Type | Description |
---|---|
TaskInfo
|
The details of the task. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples:
>>> from meilisearch_python_sdk import AsyncClient
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
>>> await client.create_dump()
Source code in meilisearch_python_sdk/_client.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
create_index(uid, primary_key=None, *, settings=None, wait=True, timeout_in_ms=None, plugins=None, hits_type=JsonDict)
async
Creates a new index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
The index's unique identifier. |
required |
primary_key
|
str | None
|
The primary key of the documents. Defaults to None. |
None
|
settings
|
MeilisearchSettings | None
|
Settings for the index. The settings can also be updated independently of creating the index. The advantage to updating them here is updating the settings after adding documents will cause the documents to be re-indexed. Because of this it will be faster to update them before adding documents. Defaults to None (i.e. default Meilisearch index settings). |
None
|
wait
|
bool
|
If set to True and settings are being updated, the index will be returned after the settings update has completed. If False it will not wait for settings to complete. Default: True |
True
|
timeout_in_ms
|
int | None
|
Amount of time in milliseconds to wait before raising a
MeilisearchTimeoutError. |
None
|
plugins
|
AsyncIndexPlugins | None
|
Optional plugins can be provided to extend functionality. |
None
|
hits_type
|
Any
|
Allows for a custom type to be passed to use for hits. Defaults to JsonDict |
JsonDict
|
Returns:
Type | Description |
---|---|
AsyncIndex
|
An instance of AsyncIndex containing the information of the newly created index. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples:
>>> from meilisearch_python_sdk import AsyncClient
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
>>> index = await client.create_index("movies")
Source code in meilisearch_python_sdk/_client.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|
create_key(key)
async
Creates a new API key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
KeyCreate
|
The information to use in creating the key. Note that if an expires_at value is included it should be in UTC time. |
required |
Returns:
Type | Description |
---|---|
Key
|
The new API key. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> from meilissearch_async_client.models.client import KeyCreate >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> key_info = KeyCreate( >>> description="My new key", >>> actions=["search"], >>> indexes=["movies"], >>> ) >>> keys = await client.create_key(key_info)
Source code in meilisearch_python_sdk/_client.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
|
create_snapshot()
async
Trigger the creation of a Meilisearch snapshot.
Returns:
Type | Description |
---|---|
TaskInfo
|
The details of the task. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples:
>>> from meilisearch_python_sdk import AsyncClient
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
>>> await client.create_snapshot()
Source code in meilisearch_python_sdk/_client.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
delete_index_if_exists(uid)
async
Deletes an index if it already exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
The index's unique identifier. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if an index was deleted for False if not. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples:
>>> from meilisearch_python_sdk import AsyncClient
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
>>> await client.delete_index_if_exists()
Source code in meilisearch_python_sdk/_client.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
|
delete_key(key)
async
Deletes an API key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The key or uid to delete. |
required |
Returns:
Type | Description |
---|---|
int
|
The Response status code. 204 signifies a successful delete. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> await client.delete_key("abc123")
Source code in meilisearch_python_sdk/_client.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
delete_tasks(*, uids=None, index_uids=None, statuses=None, types=None, before_enqueued_at=None, after_enqueued_at=None, before_started_at=None, after_finished_at=None)
async
Delete a list of tasks.
Defaults to deleting all tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uids
|
list[str] | None
|
A list of task UIDs to delete. |
None
|
index_uids
|
list[str] | None
|
A list of index UIDs for which to delete tasks. |
None
|
statuses
|
list[str] | None
|
A list of statuses to delete. |
None
|
types
|
list[str] | None
|
A list of types to delete. |
None
|
before_enqueued_at
|
datetime | None
|
Delete tasks that were enqueued before the specified date time. |
None
|
after_enqueued_at
|
datetime | None
|
Delete tasks that were enqueued after the specified date time. |
None
|
before_started_at
|
datetime | None
|
Delete tasks that were started before the specified date time. |
None
|
after_finished_at
|
datetime | None
|
Delete tasks that were finished after the specified date time. |
None
|
Returns:
Type | Description |
---|---|
TaskInfo
|
The details of the task |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
MeilisearchTimeoutError
|
If the connection times out. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> from meilisearch_python_sdk.task import delete_tasks >>> >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> await client.delete_tasks(uids=[1, 2])
Source code in meilisearch_python_sdk/_client.py
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 |
|
get_all_stats()
async
Get stats for all indexes.
Returns:
Name | Type | Description |
---|---|---|
ClientStats
|
Information about database size and all indexes. |
|
https |
ClientStats
|
//docs.meilisearch.com/reference/api/stats.html |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> stats = await client.get_all_stats()
Source code in meilisearch_python_sdk/_client.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
get_index(uid)
async
Gets a single index based on the uid of the index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
The index's unique identifier. |
required |
Returns:
Type | Description |
---|---|
AsyncIndex
|
An AsyncIndex instance containing the information of the fetched index. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples:
>>> from meilisearch_python_sdk import AsyncClient
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
>>> index = await client.get_index()
Source code in meilisearch_python_sdk/_client.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|
get_indexes(*, offset=None, limit=None)
async
Get all indexes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
int | None
|
Number of indexes to skip. The default of None will use the Meilisearch default. |
None
|
limit
|
int | None
|
Number of indexes to return. The default of None will use the Meilisearch default. |
None
|
Returns:
Type | Description |
---|---|
list[AsyncIndex] | None
|
A list of all indexes. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples:
>>> from meilisearch_python_sdk import AsyncClient
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
>>> indexes = await client.get_indexes()
Source code in meilisearch_python_sdk/_client.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
get_key(key)
async
Gets information about a specific API key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The key for which to retrieve the information. |
required |
Returns:
Type | Description |
---|---|
Key
|
The API key, or |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> keys = await client.get_key("abc123")
Source code in meilisearch_python_sdk/_client.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
|
get_keys(*, offset=None, limit=None)
async
Gets the Meilisearch API keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
int | None
|
Number of indexes to skip. The default of None will use the Meilisearch default. |
None
|
limit
|
int | None
|
Number of indexes to return. The default of None will use the Meilisearch default. |
None
|
Returns:
Type | Description |
---|---|
KeySearch
|
API keys. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples from meilisearch_python_sdk import AsyncClient async with AsyncClient("http://localhost.com", "masterKey") as client: keys = await client.get_keys()
Source code in meilisearch_python_sdk/_client.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
get_or_create_index(uid, primary_key=None, *, plugins=None, hits_type=JsonDict)
async
Get an index, or create it if it doesn't exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
The index's unique identifier. |
required |
primary_key
|
str | None
|
The primary key of the documents. Defaults to None. |
None
|
plugins
|
AsyncIndexPlugins | None
|
Optional plugins can be provided to extend functionality. |
None
|
hits_type
|
Any
|
Allows for a custom type to be passed to use for hits. Defaults to JsonDict |
JsonDict
|
Returns:
Type | Description |
---|---|
AsyncIndex
|
An instance of AsyncIndex containing the information of the retrieved or newly created index. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error.MeilisearchTimeoutError: If the connection times out. |
MeilisearchTimeoutError
|
If the connection times out. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> index = await client.get_or_create_index("movies")
Source code in meilisearch_python_sdk/_client.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
get_raw_index(uid)
async
Gets the index and returns all the index information rather than an AsyncIndex instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
The index's unique identifier. |
required |
Returns:
Type | Description |
---|---|
IndexInfo | None
|
Index information rather than an AsyncIndex instance. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> index = await client.get_raw_index("movies")
Source code in meilisearch_python_sdk/_client.py
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
|
get_raw_indexes(*, offset=None, limit=None)
async
Gets all the indexes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
int | None
|
Number of indexes to skip. The default of None will use the Meilisearch default. |
None
|
limit
|
int | None
|
Number of indexes to return. The default of None will use the Meilisearch default. |
None
|
Returns all the index information rather than an AsyncIndex instance.
Returns:
Type | Description |
---|---|
list[IndexInfo] | None
|
A list of the Index information rather than an AsyncIndex instances. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> index = await client.get_raw_indexes()
Source code in meilisearch_python_sdk/_client.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 |
|
get_task(task_id)
async
Get a single task from it's task id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
int
|
Identifier of the task to retrieve. |
required |
Returns:
Type | Description |
---|---|
TaskResult
|
Results of a task. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
MeilisearchTimeoutError
|
If the connection times out. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> from meilisearch_python_sdk.task import get_task >>> >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> await client.get_task(client, 1244)
Source code in meilisearch_python_sdk/_client.py
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 |
|
get_tasks(*, index_ids=None, types=None, reverse=None)
async
Get multiple tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index_ids
|
list[str] | None
|
A list of index UIDs for which to get the tasks. If provided this will get the tasks only for the specified indexes, if not all tasks will be returned. Default = None |
None
|
types
|
str | list[str] | None
|
Specify specific task types to retrieve. Default = None |
None
|
reverse
|
bool | None
|
If True the tasks will be returned in reverse order. Default = None |
None
|
Returns:
Type | Description |
---|---|
TaskStatus
|
Task statuses. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
MeilisearchTimeoutError
|
If the connection times out. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> await client.get_tasks()
Source code in meilisearch_python_sdk/_client.py
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
|
get_version()
async
Get the Meilisearch version.
Returns:
Type | Description |
---|---|
Version
|
Information about the version of Meilisearch. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> version = await client.get_version()
Source code in meilisearch_python_sdk/_client.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
|
health()
async
Get health of the Meilisearch server.
Returns:
Type | Description |
---|---|
Health
|
The status of the Meilisearch server. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> health = await client.get_health()
Source code in meilisearch_python_sdk/_client.py
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
|
index(uid, *, plugins=None)
Create a local reference to an index identified by UID, without making an HTTP call.
Because no network call is made this method is not awaitable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
The index's unique identifier. |
required |
plugins
|
AsyncIndexPlugins | None
|
Optional plugins can be provided to extend functionality. |
None
|
Returns:
Type | Description |
---|---|
AsyncIndex
|
An AsyncIndex instance. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples:
>>> from meilisearch_python_sdk import AsyncClient
>>> async with AsyncClient("http://localhost.com", "masterKey") as client:
>>> index = client.index("movies")
Source code in meilisearch_python_sdk/_client.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
multi_search(queries, *, federation=None, hits_type=JsonDict)
async
Multi-index search.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
queries
|
list[SearchParams]
|
List of SearchParameters |
required |
federation
|
Federation | FederationMerged | None
|
If included a single search result with hits built from all queries will be returned. This parameter can only be used with Meilisearch >= v1.10.0. Defaults to None. |
None
|
hits_type
|
Any
|
Allows for a custom type to be passed to use for hits. Defaults to JsonDict |
JsonDict
|
Returns:
Type | Description |
---|---|
list[SearchResultsWithUID] | SearchResultsFederated
|
Results of the search |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> from meilisearch_python_sdk.models.search import SearchParams >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> queries = [ >>> SearchParams(index_uid="my_first_index", query"Some search"), >>> SearchParams(index_uid="my_second_index", query="Another search") >>> ] >>> search_results = await client.search(queries)
Source code in meilisearch_python_sdk/_client.py
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
|
swap_indexes(indexes)
async
Swap two indexes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indexes
|
list[tuple[str, str]]
|
A list of tuples, each tuple should contain the indexes to swap. |
required |
Returns:
Type | Description |
---|---|
TaskInfo
|
The details of the task. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> index = await client.swap_indexes([("index_a", "index_b")])
Source code in meilisearch_python_sdk/_client.py
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
|
update_key(key)
async
Update an API key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
KeyUpdate
|
The information to use in updating the key. Note that if an expires_at value is included it should be in UTC time. |
required |
Returns:
Type | Description |
---|---|
Key
|
The updated API key. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> from meilissearch_async_client.models.client import KeyUpdate >>> async with AsyncClient("http://localhost.com", "masterKey") as client: >>> key_info = KeyUpdate( key="abc123", >>> indexes=["*"], >>> ) >>> keys = await client.update_key(key_info)
Source code in meilisearch_python_sdk/_client.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
|
wait_for_task(task_id, *, timeout_in_ms=5000, interval_in_ms=50, raise_for_status=False)
async
Wait until Meilisearch processes a task, and get its status.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
int
|
Identifier of the task to retrieve. |
required |
timeout_in_ms
|
int | None
|
Amount of time in milliseconds to wait before raising a
MeilisearchTimeoutError. |
5000
|
interval_in_ms
|
int
|
Time interval in miliseconds to sleep between requests. Defaults to 50. |
50
|
raise_for_status
|
bool
|
When set to |
False
|
Returns:
Type | Description |
---|---|
TaskResult
|
Details of the processed update status. |
Raises:
Type | Description |
---|---|
MeilisearchCommunicationError
|
If there was an error communicating with the server. |
MeilisearchApiError
|
If the Meilisearch API returned an error. |
MeilisearchTimeoutError
|
If the connection times out. |
MeilisearchTaskFailedError
|
If |
Examples >>> from meilisearch_python_sdk import AsyncClient >>> >>> documents = [ >>> {"id": 1, "title": "Movie 1", "genre": "comedy"}, >>> {"id": 2, "title": "Movie 2", "genre": "drama"}, >>> ] >>> async with Client("http://localhost.com", "masterKey") as client: >>> index = client.index("movies") >>> response = await index.add_documents(documents) >>> await client.wait_for_task(client, response.update_id)
Source code in meilisearch_python_sdk/_client.py
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 |
|