Skip to main content

A decorator to check for indexing status errors

Project description

MeiliSearch Status Check Decorator

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(documents=documents, 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'}

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.0.tar.gz (3.3 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.0.tar.gz.

File metadata

File hashes

Hashes for meilisearch-status-check-decorator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 605777841be0f24955cf2f338c7411ba2f6bc6e243f72f0b548fc6212e06433c
MD5 36087789be3a35bca5dae933cd9fd861
BLAKE2b-256 3771d626f30c6fbbc84533c099b65df70042d6caa920bf96248d414f842d5d42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for meilisearch_status_check_decorator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9c95ed036026cc897ffcebf528955f387650fb6eedc15e8f653b82b977f99fd
MD5 9adeb808f38c152e520de431eb605233
BLAKE2b-256 b54d113bc4b5d8badaea407e8663f2d723315ef94a95cacec52f37c4a8e9fa45

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