Index create and update methods should map body into json and send to MeiliSearch
See original GitHub issueCurrently, 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:
- Created 3 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 😄
I close since this part was removed!