Skip to content

Commit 372c082

Browse files
authored
Merge pull request #1057 from samuelbradshaw/add-documents-documentation
Improve documentation for Index.add_documents() methods
2 parents 9eed5bd + 9962ffa commit 372c082

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

meilisearch/_httprequests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def send_request(
3333
Mapping[str, Any],
3434
Sequence[Mapping[str, Any]],
3535
List[str],
36+
bytes,
3637
str,
3738
int,
3839
ProximityPrecision,
@@ -84,7 +85,7 @@ def post(
8485
self,
8586
path: str,
8687
body: Optional[
87-
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], str]
88+
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], bytes, str]
8889
] = None,
8990
content_type: Optional[str] = "application/json",
9091
*,
@@ -96,7 +97,7 @@ def patch(
9697
self,
9798
path: str,
9899
body: Optional[
99-
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], str]
100+
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], bytes, str]
100101
] = None,
101102
content_type: Optional[str] = "application/json",
102103
) -> Any:
@@ -110,6 +111,7 @@ def put(
110111
Mapping[str, Any],
111112
Sequence[Mapping[str, Any]],
112113
List[str],
114+
bytes,
113115
str,
114116
int,
115117
ProximityPrecision,

meilisearch/index.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -484,17 +484,17 @@ def add_documents_in_batches(
484484

485485
def add_documents_json(
486486
self,
487-
str_documents: str,
487+
str_documents: bytes,
488488
primary_key: Optional[str] = None,
489489
*,
490490
serializer: Optional[Type[JSONEncoder]] = None,
491491
) -> TaskInfo:
492-
"""Add string documents from JSON file to the index.
492+
"""Add documents to the index from a byte-encoded JSON string.
493493
494494
Parameters
495495
----------
496496
str_documents:
497-
String of document from a JSON file.
497+
Byte-encoded JSON string.
498498
primary_key (optional):
499499
The primary-key used in index. Ignored if already set up.
500500
serializer (optional):
@@ -518,16 +518,16 @@ def add_documents_json(
518518

519519
def add_documents_csv(
520520
self,
521-
str_documents: str,
521+
str_documents: bytes,
522522
primary_key: Optional[str] = None,
523523
csv_delimiter: Optional[str] = None,
524524
) -> TaskInfo:
525-
"""Add string documents from a CSV file to the index.
525+
"""Add documents to the index from a byte-encoded CSV string.
526526
527527
Parameters
528528
----------
529529
str_documents:
530-
String of document from a CSV file.
530+
Byte-encoded CSV string.
531531
primary_key (optional):
532532
The primary-key used in index. Ignored if already set up.
533533
csv_delimiter:
@@ -548,15 +548,15 @@ def add_documents_csv(
548548

549549
def add_documents_ndjson(
550550
self,
551-
str_documents: str,
551+
str_documents: bytes,
552552
primary_key: Optional[str] = None,
553553
) -> TaskInfo:
554-
"""Add string documents from a NDJSON file to the index.
554+
"""Add documents to the index from a byte-encoded NDJSON string.
555555
556556
Parameters
557557
----------
558558
str_documents:
559-
String of document from a NDJSON file.
559+
Byte-encoded NDJSON string.
560560
primary_key (optional):
561561
The primary-key used in index. Ignored if already set up.
562562
@@ -575,24 +575,24 @@ def add_documents_ndjson(
575575

576576
def add_documents_raw(
577577
self,
578-
str_documents: str,
578+
str_documents: bytes,
579579
primary_key: Optional[str] = None,
580580
content_type: Optional[str] = None,
581581
csv_delimiter: Optional[str] = None,
582582
*,
583583
serializer: Optional[Type[JSONEncoder]] = None,
584584
) -> TaskInfo:
585-
"""Add string documents to the index.
585+
"""Add documents to the index from a byte-encoded string.
586586
587587
Parameters
588588
----------
589589
str_documents:
590-
String of document.
590+
Byte-encoded string.
591+
content_type:
592+
The content MIME type: 'application/json', 'application/x-dnjson', or 'text/csv'.
591593
primary_key (optional):
592594
The primary-key used in index. Ignored if already set up.
593-
type:
594-
The type of document. Type available: 'csv', 'json', 'jsonl'.
595-
csv_delimiter:
595+
csv_delimiter (optional):
596596
One ASCII character used to customize the delimiter for CSV.
597597
Note: The csv delimiter can only be used with the Content-Type text/csv.
598598
serializer (optional):

0 commit comments

Comments
 (0)