question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bidoubiwacommented, Jun 3, 2020

Yes! It was indeed to make it safer but either we check everything we send to MeiliSearch, either we let meilisearch handle the errors. So lets remove it 😄

0reactions
curquizacommented, Aug 11, 2020

I close since this part was removed!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MeiliSearch: A definitive guide - LogRocket Blog
Creating the blogs index; Uploading a dataset in MeiliSearch; Searching for documents in MeiliSearch; How to modify documents with MeiliSearch ...
Read more >
Documents | Meilisearch Documentation v0.28
Delete a selection of documents based on array of document id's. The index uid is required. # Body. The body must be a...
Read more >
Indexes | Meilisearch Documentation v0.30
Auto-generated on index creation or update ... GET. /indexes. List all indexes. Results can be paginated by using the offset and limit query...
Read more >
Quick start | Meilisearch Documentation v0.30
Documents are grouped into collections, called indexes. NOTE. Meilisearch currently only accepts data in JSON, NDJSON, and CSV formats. You can read more...
Read more >
Documents | Meilisearch Documentation v0.30
Meilisearch will only accept JSON documents when it receives the application/json content-type header. As an example, let's say you are creating an index...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found