Giter Site home page Giter Site logo

meilisearch-python's Introduction

Meilisearch-Python

Meilisearch Python

PyPI version Test Status License Bors enabled

โšก The Meilisearch API client written for Python ๐Ÿ

Meilisearch Python is the Meilisearch API client for Python developers.

Meilisearch is an open-source search engine. Learn more about Meilisearch.

Table of Contents

๐Ÿ“– Documentation

To learn more about Meilisearch Python, refer to the in-depth Meilisearch Python documentation. To learn more about Meilisearch in general, refer to our documentation or our API reference.

โšก Supercharge your Meilisearch experience

Say goodbye to server deployment and manual updates with Meilisearch Cloud. Get started with a 14-day free trial! No credit card required.

๐Ÿ”ง Installation

Note: Python 3.8+ is required.

With pip3 in command line:

pip3 install meilisearch

Run Meilisearch

There are many easy ways to download and run a Meilisearch instance.

For example, using the curl command in your Terminal:

# Install Meilisearch
curl -L https://install.meilisearch.com | sh

# Launch Meilisearch
./meilisearch --master-key=masterKey

NB: you can also download Meilisearch from Homebrew or APT or even run it using Docker.

๐Ÿš€ Getting started

Add Documents

import meilisearch

client = meilisearch.Client('http://127.0.0.1:7700', 'masterKey')

# An index is where the documents are stored.
index = client.index('movies')

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'] },
]

# If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
index.add_documents(documents) # => { "uid": 0 }

With the task uid, you can check the status (enqueued, canceled, processing, succeeded or failed) of your documents addition using the task.

Basic Search

# Meilisearch is typo-tolerant:
index.search('caorl')

Output:

{
  "hits": [
    {
      "id": 1,
      "title": "Carol",
      "genre": ["Romance", "Drama"]
    }
  ],
  "offset": 0,
  "limit": 20,
  "processingTimeMs": 1,
  "query": "caorl"
}

Custom Search

All the supported options are described in the search parameters

index.search(
  'phil',
  {
    'attributesToHighlight': ['*'],
  }
)

JSON output:

{
  "hits": [
    {
      "id": 6,
      "title": "Philadelphia",
      "_formatted": {
        "id": 6,
        "title": "<em>Phil</em>adelphia",
        "genre": ["Drama"]
      }
    }
  ],
  "offset": 0,
  "limit": 20,
  "processingTimeMs": 0,
  "query": "phil"
}

Custom Search With Filters

If you want to enable filtering, you must add your attributes to the filterableAttributes index setting.

index.update_filterable_attributes([
  'id',
  'genres'
])

You only need to perform this operation once.

Note that Meilisearch will rebuild your index whenever you update filterableAttributes. Depending on the size of your dataset, this might take time. You can track the process using the task.

Then, you can perform the search:

index.search(
  'wonder',
  {
    'filter': ['id > 1 AND genres = Action']
  }
)
{
  "hits": [
    {
      "id": 2,
      "title": "Wonder Woman",
      "genres": ["Action", "Adventure"]
    }
  ],
  "offset": 0,
  "limit": 20,
  "estimatedTotalHits": 1,
  "processingTimeMs": 0,
  "query": "wonder"
}

๐Ÿค– Compatibility with Meilisearch

This package guarantees compatibility with version v1.x of Meilisearch, but some features may not be present. Please check the issues for more info.

๐Ÿ’ก Learn more

The following sections in our main documentation website may interest you:

โš™๏ธ Contributing

Any new contribution is more than welcome in this project!

If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!


Meilisearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.

meilisearch-python's People

Contributors

adripo avatar alallema avatar ambareen09 avatar azanul avatar bidoubiwa avatar bors[bot] avatar brunoocasali avatar carofg avatar curquiza avatar cyprx avatar dark-rock avatar dependabot-preview[bot] avatar dependabot[bot] avatar elamcsquared avatar ellnix avatar eskombro avatar geeksambhu avatar kamyar avatar kshivendu avatar leigh-ola avatar meili-bors[bot] avatar meili-bot avatar mk1107 avatar moazfarrukh avatar pbelokon avatar rogerzecat avatar sanders41 avatar seluj78 avatar strift avatar tpayet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meilisearch-python's Issues

Setting timeouts

Hi!

Looking at the code, I cannot see a way to expose timeouts. I need this because my app became unresponsive when meilisearch was unavailable.

A nice pattern for achieving this is to be able to pass in a requests.Session when creating the client, which means you can expose all of the requests goodness with minimal work.

Option to auto-start the Docker container for tests

For my projects that use Python and Docker together I have created an autouse session scoped fixture to automatically start the Docker container if it isn't running. The way it work is it checks the expected port (port 7700 in this case) at startup and if the port is in use it assumes the container is already running so it does nothing. If nothing is running on the port it starts the container for the tests, then stop it when the tests complete.

Because it first checks for a running container there would be no changes made to the current CI workflow because the fixture would see that the container is already running not start a new one. The same would be true if you still want to start you own container before testing, nothing would change from how it currently works in this scenario.

The difference would be that if you don't start a container before running the test suite, a container would automatically start for you so the tests wouldn't fail (at least not because there was no container running).

Would there be any interest in adding this fixture to this project? Or maybe not everyone is using Docker to run the tests here? If that is the case it should still work as expected if MeiliSearch is running on port 7700 (the fixture should see this and not start a container). If there is interest in using the fixture, I could test this scenario to be sure it works as expected.

create_index and get_index giving json error

Hello everyone, i am trying to create a new index using python but it shows json error. i dont understand why. this is my sample code which i am trying to run.
import meilisearch
client = meilisearch.Client('http://example', 'master key')
index = client.create_index('new_index') # line3
d = [some dictionary]
index.add_documents(d) #line 5

earlier it was showing the same json error on "line 5" i cross checked the type of the document being inserted it was all fine but after a few iterations with the same error , the same error occured in "line 3". this is the error which i am getting

File "m_smk.py", line 7, in <module>
index = client.create_index('new_index')
File "/home/mudit/.local/lib/python3.8/site-packages/meilisearch/client.py", line 52, in create_index
index.create(self.config, uid, options)
File "/home/mudit/.local/lib/python3.8/site-packages/meilisearch/index.py", line 109, in create
return HttpRequests(config).post(config.paths.index, payload)
File "/home/mudit/.local/lib/python3.8/site-packages/meilisearch/_httprequests.py", line 31, in post
return self.send_request(requests.post, path, body)
File "/home/mudit/.local/lib/python3.8/site-packages/meilisearch/_httprequests.py", line 23, in send_request
return self.__validate(request)
File "/home/mudit/.local/lib/python3.8/site-packages/meilisearch/_httprequests.py", line 51, in __validate
raise MeiliSearchApiError(err, request)
File "/home/mudit/.local/lib/python3.8/site-packages/meilisearch/errors.py", line 19, in __init__
self.message = f'{json.loads(request.text)["message"]}'
File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Can someone help me out with this error? Is this something related to the new updates of meilisearch? i am using python version 3.8.3.
PS: I haven't updated it yet and don't know how to update it.

Error handler

It could be better for this package to have its own error handler.

Not an emergency.

Adding documents with primary key not working

When adding documents and including a primary key, the primary key is getting set to None instead of the specified key. For example:

index.add_documents(small_movies, primary_key="title")
print(index.get_primary_key())

results in None being printed. Maybe I'm just not correctly understanding how to use the primary_key? The correct url of indexes/some-uid/documents?primaryKey=title is being generated. so the add_documents method seem to be doing what it is supposed to do.

Inheritance refactoring

Currently, the sens of inheritance is (from parent to children classes)
Document, Settings... -> Index.
And: HttpReqest is used as a module

What we should have:
HttpRequest -> Index and Client

This is more logical because Index and Client are classes to communicate with MeiliSearch, so it should inherit the HttpRequest properties to actually do this communication.
This way, we could avoid a lot of duplicated codes, specifically with the config parts. When instantiating Index, the parent constructor (HttpReuest one) would be called, and they will share the same configuration without passing config everywhere.

Improve tests

The number of tests and their relevancy should be improved.

Some clues:

  • do not test only if the response is a list or a dict: we should check that the response contains some keys and values.
  • When testing an asynchronous method, we should only check that the response contains an updateId: we should check that the action has been well executed.
    ex: if testing document addition, we need to check that the documents have been added too.

Python 3.9

I have been using Python 3.9 without issue, and I just noticed that 3.9 is not listed as a supported version. I ran the test suite on 3.9 and all tests passed. Is it OK if I add 3.9 to the list of supported versions?

Missing code samples

An update has been made on the code-samples list of samples.

The following samples are missing from this repository .code-samples.meilisearch.yaml

get_attributes_for_faceting_1
update_attributes_for_faceting_1
reset_attributes_for_faceting_1
settings_guide_synonyms_1
add_movies_json_1

To know what we expect from these specific samples, please visit the cURL sample file.

Exemple for get_attributes_for_faceting_1:

get_attributes_for_faceting_1: |-
  $ curl \
    -X GET 'http://localhost:7700/indexes/movies/settings/attributes-for-faceting'

Create and fill sample file to display Python examples in MeiliSearch Documentation

Code Samples for MeiliSearch documentation

Introduction

As MeiliSearch grows so does its SDK's. More and more SDK's rises from the ground and they all deserve to be as well documented as the core engine itself.

The most common way for a user to understand MeiliSearch is to go to its official documentation. As of yesterday all examples in the documentation were made with cURL. Unfortunately, most of our users do not communicate with MeiliSearch directly with cURL. Which forces them to search for the specific references somewhere else (in the readme's, in the sdk's code itself,..). This makes for unnecessary friction.

Goal

We want our documentation to include all SDK's

As a first step we want all examples to be made using the most possible SDK's. As did Stripe and Algolia.

sdk_sample

examples with curl and javascript SDK and soon enough this SDK too!

To achieve this it is expected from this SDK to create a sample file containing all the code samples needed by the documentation.

These are the steps to follow:

  • Create your sample file
  • Fill your sample file
  • Add your samples to the documentation

Create your sample file

The sample file is a yaml file added at the root of each MeiliSearch SDK.
Sample files are created based on the sample-template.yaml file.

sample-template file:

get_one_index_1: |-
list_all_indexes_1: |-
create_an_index_1: |-
...

This template is accessible publicly here or in the public directory : .vuepress/public/sample-template.yaml of the documentation.

The name of the file should be .code-samples.meilisearch.yaml

Fill your sample file

After creating the sample file with the content of the sample template you should have a file containing all the sampleId's.

get_one_index_1: |-
list_all_indexes_1: |-
create_an_index_1: |-
...

By the name of the different sampleId you should know where that code sample will be added to the documentation.

For example, create_an_index_1 is the first example in the API References of the index creation.

Using the already existing cURL example in the documentation you should see what is expected from that sample. It is very important that you look at the already existing samples in the documentation as it gives you the parameters to use in your sample to match with the rest of the documentation.

Good sample based on documentation:

create_an_index_1: |-
  client.createIndex({ uid: 'movies' })

Bad sample that does not match with the response.

create_an_index_1: |-
  client.createIndex({ uid: 'otherName' })

Each sample is expected to be written in the respective SDK language.

Javascript example:

get_one_index_1: |-
  client.getIndex('movies').show()
list_all_indexes_1: |-
  client.listIndexes()
create_an_index_1: |-
  client.createIndex({ uid: 'movies' })
  ...

The complete cURL sample file is available at the root of the documentation repository.
Every other SDK sample file should be available at the root of their respective repository.

Formatting Exception

There is one exception to the formatting rule.
When the sampleId finishes with _md it means it is expected to be written in markdown format.

JavaScript sample id with _md extension:
yaml-js-example

Add your samples to the documentation

Once your sample file is filled with the code samples, you will need to create a pull request on the documentation repository.

Open the following file in your IDE:
.vuepress/code-samples/sdks.json

And add your sample file to the list:

[
  ...
  {
    "language": "sdk-language",
    "label": "sdk-label",
    "url": "url to yaml file"
  }
]

The language key expect a supported language for the code highlight.

The label key is the name of the tab. While label and language could have been the same, it created some conflict (i.e: bash and cURL).

The url is the raw link to access your sample file. It should look like this:
https://raw.githubusercontent.com/[PROJECT]/[REPO]/.code-samples.meilisearch.yaml

Search route badly formatted

The search route should have this as a prototype :

index.search(query: string, [options: object])

Options being optional and query mandatory.

Using relative imports !

from .index import Index
from .health import Health
from .key import Key
from .config import Config
from .sys_info import SysInfo
from .stat import Stat
from .version import Version

In client.py (and many others) you are using relative imports. You should change it to

from meilisearch.index import Index 
from meilisearch.health import Health 
from meilisearch.key import Key 
from meilisearch.config import Config 
from meilisearch.sys_info import SysInfo 
from meilisearch.stat import Stat 
from meilisearch.version import Version

Update code-sample about updateDocuments

Related to: meilisearch/documentation#405

Could you update

add_or_update_documents_1: |-
  client.get_index('movies').update_documents([{
    'id': 287947,
    'title': 'Shazam12'
  }])

with

add_or_update_documents_1: |-
  client.get_index('movies').update_documents([{
      'id': 287947,
      title: 'Shazam โšก๏ธ',
      genre: 'comedy'
  }])

Index create and update methods should map body into json and send to MeiliSearch

Currently, this methods accept a body parameter, look for the requested fields inside of that body and send them in the payload. In this case, the SDK is not necessarily relying in the MeiliSearch API, but manipulating the user data to build a payload before sending it to MeiliSearch. This can introduce new errors that don't necessarily correspond to the MeiliSearch API errors, and it is not really transparent. It looks like this:

    @staticmethod
    def create(config, **body):
        """Create an index.
        Parameters
        ----------
            body: **kwargs
            Accepts uid, name and primaryKey as parameter.
        Returns
        -------
        index : Index
            an instance of Index containing the information of the newly created index
        Raises
        ------
        HTTPError
            In case of any error found here https://docs.meilisearch.com/references/#errors-status-code
        """
        payload = {}
        uid = body.get('uid', None)
        if uid is not None:
            payload['uid'] = uid
        name = body.get('name', None)
        if name is not None:
            payload['name'] = name
        primary_key = body.get('primary_key', None)
        if primary_key is not None:
            payload['primaryKey'] = primary_key
        return HttpRequests(config).post(config.paths.index, payload)

This methods should only transform the body into a json, and send it as the payload to MeiliSearch. If there is a problem with the json body, errors should be handled by MeiliSearch itself, and not the SDK.

Use error code instead of error message

As referenced here meilisearch/meilisearch#683 MeiliSearch will rely now on error codes instead of error messages. This makes it possible to modify error messages without having an impact in the SDK behavior. Python SDK relayed in error messages, specially when trying to create an index that exists already in the MeiliSearch instance.

The MeiliSearchApiError should now find the error code, error message and error link pointing to the documentation.

get_keys doc string incorrect

I believe the doc string for the get_keys method in the Client is incorrect. It says a list of keys is return, but this should say a dictionary is returned correct? I will submit a PR to correct this. If I am understanding wrong and list is correct apologizes, and obviously ignore and close the PR in that case.

Change master branch to main

Let's be allies and make this change that means a lot.

Here is a blog post that explain a little more why it's important, and how to easily do it. It will be a bit more complicated with automation, but we still should do it!

Search no longer works after upgrading MeiliSearch

Hello. I built the wagtail-meilisearch backend for the Wagtail CMS, and I'm trying to update it to use more recent versions of MeiliSearch, but since upgrading MeiliSearch and meilisearch-python I get an error when searching the index that I had previously built...

/usr/lib/python3.6/site-packages/meilisearch/_httprequests.py in __validate(request)
     49             return HttpRequests.__to_json(request)
     50         except requests.exceptions.HTTPError as err:
---> 51             raise MeiliSearchApiError(err, request)

MeiliSearchApiError: MeiliSearchApiError. Error code: search_error. Error message: impossible to search documents; heed error; error while decoding. Error documentation: https://docs.meilisearch.com/error/search_error

The link to the error documentation at the end there is a 404, I was able to find the relevant page on the docs but it didn't help much. Should I kill and rebuild the index from scratch after upgrading?

Specify minimal python version in readme

There is a lot of breaking backward compatibility feature in python minor version (like type hints in 3.5 or f string in 3.6) and there is a lot of breaking changes between python 2 and python 3.

So, you should specify the minimal python version required to use this package for more readability.

Python versions in tests

It is currently listed that Python versions 3.5 through 3.8 are supported however the tests, including CI tests, are only run against 3.7. It would be good to add the other versions to the CI tests and possibly add tox to be able to test all versions locally also.

Setting a primary key when it already exists is not handled

As for now, updating an index does:

def update(self, **body):
        """Update an index from meilisearch

        Parameters
        ----------
        body: **kwargs
            Accepts primaryKey as an updatable parameter.

        Returns
        ----------
        update: `dict`
            Dictionnary containing an update id to track the action:
            https://docs.meilisearch.com/references/updates.html#get-an-update-status
        """
        payload = {}
        primary_key = body.get('primaryKey', None)
        if primary_key is not None:
            payload['primaryKey'] = primary_key
        return self.http.put('{}/{}'.format(self.config.paths.index, self.uid), payload)

If the primary key is already set, this function will just ignore the primary key the user is sending, without raising an exception or notifying the user. We should handle this case

Typo in create an index section of the python API documentation

Replicating this example: https://docs.meilisearch.com/references/indexes.html#create-an-index, it get the following error:

meilisearch.errors.MeiliSearchApiError: MeiliSearchApiError. 
Error code: bad_request. Error message: Invalid JSON: unknown field `primary_key`, 
expected one of `name`, `uid`, `primaryKey` at line 1 column 14. 
Error documentation: https://docs.meilisearch.com/errors#bad_request

The dictionary key for creating specifying the primary key of a new index should be "primaryKey" and not "primary_key" in the docs.

async await?

Python asyncio? Async await

Used with the current asynchronous web framework of Python

Document.get_documents default parameters broken.

Running the following code raises a type error

index.get_documents()
... 
TypeError: not a valid non-string sequence or mapping object

The culprit seems to be default value of parameters is None and urlencode needs a list or dict

 urllib.parse.urlencode(None)
TypeError: not a valid non-string sequence or mapping object

A workaround is passing an empty dict.

index.get_documents({})

A possible solution is changing the default value of parameters to an empty dict or list.

Relevant code :

def get_documents(self, parameters=None):
"""Get a set of documents from the index
Parameters
----------
parameters (optional): dict
parameters accepted by the get documents route: https://docs.meilisearch.com/references/documents.html#get-all-documents
Returns
----------
document: `dict`
Dictionnary containing the documents information
"""
return HttpRequests.get(
self.config,
'{}/{}/{}?{}'.format(
self.index_path,
self.uid,
self.document_path,
urllib.parse.urlencode(parameters))
)

Clear all indexes before each context of test

When running a test context (a class) in tests section, we don't currently clean all indexes in the MeiliSearch instance. If there are remaining indexes, it can lead to tests failure.

We should provide clean testing contexts to test exactly what we expect, and not develop in a random context.

  • Create a clear_all_indexes method
  • Call it in the setup_class method in each test context.

EDIT

The clear_all_indexes method should be a tool for tests and not a provided method because we cannot find a consensus for the moment -> cf issue

Testing isinstance

There are several tests in the test suite that test if a value is an instance of object. In Python everything behind the scenes in an object so these tests are always going to be True. For example isinstance('test', object), isinstance(1, object), and isinstance({"a": 1}, object will all return True.

I am assuming the thinking for these tests was object in a javascript context since many are testing what should be something like {"updateId": 1}. In this case the assert would instead be assert isinstance(test_value, dict) instead of assert isinstance(test_value, object)

Strings throughout the project use different formats

Throughout the project, sometimes strings are formatted with f strings and sometimes they are .format strings. For consistency it would be nice to pick one format. f strings are the more recent of the two, and I think they are more readable so that would be my vote if everyone agrees it would be good to pick one format to use throughout.

get_documents method parameter should be optional

The parameter in the method get_documents should be optional.
Indeed, the API route works well without any query parameter by default.

  • Add optional parameter
  • Add a test with no parameter
  • Add a test with an empty parameter: {}
  • Add a test with parameter: { limit: 10, ... }

unsupported operand `get_keys()`

Alright, this was working perfectly fine before, but is breaking on the same request.

python: 3.7
meilisearch: 0.10.0
meilisearch-python: 0.10.0

self.host = "http://127.0.0.1:7700"
...
client = meilisearch.Client(self.host, os.environ['MEILI_MASTER_KEY'])
config["public_api_key"]=client.get_keys()["public"]
Traceback (most recent call last):
  File "main.py", line 112, in <module>
    xss.update()
  File "main.py", line 63, in update
    config["public_api_key"]=client.get_keys()
  File "/Users/chadcarlson/.local/share/virtualenvs/search-DGRxVg4v/lib/python3.7/site-packages/meilisearch/key.py", line 37, in get_keys
    return HttpRequests.get(self.config, self.key_path)
  File "/Users/chadcarlson/.local/share/virtualenvs/search-DGRxVg4v/lib/python3.7/site-packages/meilisearch/_httprequests.py", line 8, in get
    config.url + '/' + path,
TypeError: unsupported operand type(s) for +: 'method' and 'str'

What am I missing here? Much appreciated.

C

Search parametters don't accept lists of strings (and should)

While working in the improve tests PR, #80, we realized that the search parameters like attributesToRetrieve can't handle a list of strings. you should be able to pass a list of fields, not just a single field or '*'.

The test we did and failed was:

    def test_basic_search_params_with_string_list(self):
        """Tests search with string list in query params"""
        response = self.index.search(
            'a',
            {
                'limit': 5,
                'attributesToRetrieve': ['title', 'overview'],
            }
        )
        assert isinstance(response, object)
        assert len(response['hits']) == 5
        assert "title" in response['hits'][0]
        assert "overview" in response['hits'][0]
        assert not "release_date" in response['hits'][0]

And the error shows that MeiliSearch response is sending all the fields

E       AssertionError: assert not 'release_date' in {'id': '537915', 'overview': 'A young woman falls for a guy with a dark secret and the two embark on a rocky relationship.', 'poster': 'https://image.tmdb.org/t/p/w1280/u3B2YKUjWABcxXZ6Nm9h10hLUbh.jpg', 'release_date': 1554944400, ...}

THIS TEST SHOULD BE ADDED WHEN ISSUE IS FIXED

Include message when Client Error is raised

I was using the library and was getting 400 Client Error Exception: 400 Client Error: Bad Request for url:http....

I then had to use curl to read what the error was.

I think it would be nice to include the error message returned by Meilisearch for 400 error codes so users do not have to call the API using another library or tool to debug.

The relevant piece of code:

@staticmethod
def __validate(request):
try:
request.raise_for_status()
return HttpRequests.__to_json(request)
except requests.exceptions.HTTPError as err:
raise Exception(err)
except requests.exceptions.ConnectionError as err:
raise Exception(err)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.