Skip to main content

A decorator to check for indexing status errors

Project description

MeiliSearch Status Check Decorator

Tests Status pre-commit.ci status Coverage PyPI version PyPI - Python Version

This package provides a decorator for the MeiliSearch Python client that will check for a failed status when adding documents.

Instillation

pip install meilisearch-status-check-decorator

Useage

Add documents with no errors

In this example there will be no errors so the documents will be added and the decorator will not print anything.

from meilisearch import Client
from meilisearch_status_check_decorator import status_check

index = Client("http://localhost:7700", "masterKey").index("test")


@status_check(index=index)
def good_insert():
    documents = [
      {
        "id": 1,
        "name": "test 1",
      },
      {
        "id": 2,
        "name": "test 2",
      }
    ]
    index.add_documents(documents)

Add documents with errors

In this example an error will be returned because a primary key cannot be inferred

from meilisearch import Client
from meilisearch_status_check_decorator import status_check

index = Client("http://localhost:7700", "masterKey").index("test")


@status_check(index=index)
def bad_insert():
    documents = [
      {
        "name": "test 1",
      },
      {
        "name": "test 2",
      }
    ]
    index.add_documents(documents)

This will result in an error similar to the following being printed:

FAILED: {'status': 'failed', 'updateId': 0, 'type': {'name': 'DocumentsAddition'}, 'message': 'missing primary key', 'errorCode': 'missing_primary_key', 'errorType': 'invalid_request_error', 'errorLink': 'https://docs.meilisearch.com/errors#missing_primary_key', 'duration': 0.025, 'enqueuedAt': '2021-08-29T17:06:59.877177189Z', 'processedAt': '2021-08-29T17:06:59.906190045Z'}

Contributing

Contributions to this project are welcome. If you are interesting in contributing please see our contributing guide

Project details


Download files

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

Source Distribution

meilisearch-status-check-decorator-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file meilisearch-status-check-decorator-0.1.1.tar.gz.

File metadata

File hashes

Hashes for meilisearch-status-check-decorator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 439edaa2ebe70d6e7500965da6baa249a0d912acf873d86aed127ab506661184
MD5 4226acb50e31d3baed3f4f13a287285e
BLAKE2b-256 b1395c3ff8dcce5513d2ea560eadd24b0aee87ba30ed127334ec45715cd47789

See more details on using hashes here.

File details

Details for the file meilisearch_status_check_decorator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for meilisearch_status_check_decorator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f62cb8dc0544271d5bebc4a359877f2bb597f2104c322b4d0a428eeb2aa191c
MD5 77f95207167b5f07ab3d307dd2ad3f04
BLAKE2b-256 e26d43bb1427809a7e516d6592acee4ca5ff6ce3cae4be98344f21d2b4e00ab9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page