Skip to content

Commit 24065cb

Browse files
committed
Add check for content type if csv delimiter is used
1 parent a221f94 commit 24065cb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

meilisearch/index.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ def add_documents_raw(
506506
The type of document. Type available: 'csv', 'json', 'jsonl'.
507507
csv_delimiter:
508508
One ASCII character used to customize the delimiter for CSV.
509+
Note: The csv delimiter can only be used with the Content-Type text/csv.
509510
510511
Returns
511512
-------
@@ -518,8 +519,10 @@ def add_documents_raw(
518519
MeiliSearchApiError
519520
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
520521
"""
521-
522-
url = self._build_url(primary_key=primary_key, csv_delimiter=csv_delimiter)
522+
if content_type == "text/csv":
523+
url = self._build_url(primary_key=primary_key, csv_delimiter=csv_delimiter)
524+
else:
525+
url = self._build_url(primary_key=primary_key)
523526
response = self.http.post(url, str_documents, content_type)
524527
return TaskInfo(**response)
525528

@@ -653,6 +656,7 @@ def update_documents_raw(
653656
The type of document. Type available: 'csv', 'json', 'jsonl'
654657
csv_delimiter:
655658
One ASCII character used to customize the delimiter for CSV.
659+
Note: The csv delimiter can only be used with the Content-Type text/csv.
656660
657661
Returns
658662
-------
@@ -665,7 +669,10 @@ def update_documents_raw(
665669
MeiliSearchApiError
666670
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
667671
"""
668-
url = self._build_url(primary_key=primary_key, csv_delimiter=csv_delimiter)
672+
if content_type == "text/csv":
673+
url = self._build_url(primary_key=primary_key, csv_delimiter=csv_delimiter)
674+
else:
675+
url = self._build_url(primary_key=primary_key)
669676
response = self.http.put(url, str_documents, content_type)
670677
return TaskInfo(**response)
671678

0 commit comments

Comments
 (0)