From c14cd07279e2bfb91ccf634d685c6c990703f8bf Mon Sep 17 00:00:00 2001 From: Martin J Date: Mon, 2 Dec 2024 07:42:46 +0000 Subject: [PATCH 1/3] Fix #1044 --- meilisearch/_httprequests.py | 7 ++++++- meilisearch/index.py | 13 ++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/meilisearch/_httprequests.py b/meilisearch/_httprequests.py index 5618f773..0ea38bf6 100644 --- a/meilisearch/_httprequests.py +++ b/meilisearch/_httprequests.py @@ -60,7 +60,12 @@ def send_request( data=body, ) else: - data = json.dumps(body, cls=serializer) if body else "" if body == "" else "null" + serialize_body = isinstance(body, dict) or body + data = ( + json.dumps(body, cls=serializer) + if serialize_body + else "" if body == "" else "null" + ) request = http_method( request_path, timeout=self.config.timeout, headers=self.headers, data=data diff --git a/meilisearch/index.py b/meilisearch/index.py index 30fcfa53..f668736d 100644 --- a/meilisearch/index.py +++ b/meilisearch/index.py @@ -397,17 +397,8 @@ def get_documents( MeilisearchApiError An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors """ - if parameters is None or parameters.get("filter") is None: - if parameters is None: - parameters = {} - elif "fields" in parameters and isinstance(parameters["fields"], list): - parameters["fields"] = ",".join(parameters["fields"]) - - response = self.http.get( - f"{self.config.paths.index}/{self.uid}/{self.config.paths.document}?{parse.urlencode(parameters)}" - ) - return DocumentsResults(response) - + if parameters is None: + parameters = {} response = self.http.post( f"{self.config.paths.index}/{self.uid}/{self.config.paths.document}/fetch", body=parameters, From f6897e1e142683f1eda7647aa420a981b746b67c Mon Sep 17 00:00:00 2001 From: Martin J Date: Mon, 2 Dec 2024 07:43:09 +0000 Subject: [PATCH 2/3] fix bad test syntax --- tests/index/test_index_document_meilisearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/index/test_index_document_meilisearch.py b/tests/index/test_index_document_meilisearch.py index 18947163..2669e200 100644 --- a/tests/index/test_index_document_meilisearch.py +++ b/tests/index/test_index_document_meilisearch.py @@ -224,7 +224,7 @@ def test_get_documents_offset_optional_params(index_with_documents): response = index.get_documents() assert isinstance(response.results, list) assert len(response.results) == 20 - response_offset_limit = index.get_documents({"limit": 3, "offset": 1, "fields": "title"}) + response_offset_limit = index.get_documents({"limit": 3, "offset": 1, "fields": ["title"]}) assert len(response_offset_limit.results) == 3 assert hasattr(response_offset_limit.results[0], "title") assert response_offset_limit.results[0].title == response.results[1].title From d1d617fc7d6d3f3dc1ae4c23b1a121c13c4821fc Mon Sep 17 00:00:00 2001 From: Martin J Date: Tue, 3 Dec 2024 13:09:41 +0000 Subject: [PATCH 3/3] Change README note about compatibility being limited to 1.2+ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a38c9d9..d75e7f8e 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ index.search( ## 🤖 Compatibility with Meilisearch -This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-python/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info. +This package guarantees compatibility with [version v1.2 and above of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-python/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info. ## 💡 Learn more