Skip to content

Commit

Permalink
Merge pull request #1057 from samuelbradshaw/add-documents-documentation
Browse files Browse the repository at this point in the history
Improve documentation for Index.add_documents() methods
  • Loading branch information
sanders41 authored Jan 7, 2025
2 parents 9eed5bd + 9962ffa commit 372c082
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
6 changes: 4 additions & 2 deletions meilisearch/_httprequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def send_request(
Mapping[str, Any],
Sequence[Mapping[str, Any]],
List[str],
bytes,
str,
int,
ProximityPrecision,
Expand Down Expand Up @@ -84,7 +85,7 @@ def post(
self,
path: str,
body: Optional[
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], str]
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], bytes, str]
] = None,
content_type: Optional[str] = "application/json",
*,
Expand All @@ -96,7 +97,7 @@ def patch(
self,
path: str,
body: Optional[
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], str]
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], bytes, str]
] = None,
content_type: Optional[str] = "application/json",
) -> Any:
Expand All @@ -110,6 +111,7 @@ def put(
Mapping[str, Any],
Sequence[Mapping[str, Any]],
List[str],
bytes,
str,
int,
ProximityPrecision,
Expand Down
30 changes: 15 additions & 15 deletions meilisearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,17 +484,17 @@ def add_documents_in_batches(

def add_documents_json(
self,
str_documents: str,
str_documents: bytes,
primary_key: Optional[str] = None,
*,
serializer: Optional[Type[JSONEncoder]] = None,
) -> TaskInfo:
"""Add string documents from JSON file to the index.
"""Add documents to the index from a byte-encoded JSON string.
Parameters
----------
str_documents:
String of document from a JSON file.
Byte-encoded JSON string.
primary_key (optional):
The primary-key used in index. Ignored if already set up.
serializer (optional):
Expand All @@ -518,16 +518,16 @@ def add_documents_json(

def add_documents_csv(
self,
str_documents: str,
str_documents: bytes,
primary_key: Optional[str] = None,
csv_delimiter: Optional[str] = None,
) -> TaskInfo:
"""Add string documents from a CSV file to the index.
"""Add documents to the index from a byte-encoded CSV string.
Parameters
----------
str_documents:
String of document from a CSV file.
Byte-encoded CSV string.
primary_key (optional):
The primary-key used in index. Ignored if already set up.
csv_delimiter:
Expand All @@ -548,15 +548,15 @@ def add_documents_csv(

def add_documents_ndjson(
self,
str_documents: str,
str_documents: bytes,
primary_key: Optional[str] = None,
) -> TaskInfo:
"""Add string documents from a NDJSON file to the index.
"""Add documents to the index from a byte-encoded NDJSON string.
Parameters
----------
str_documents:
String of document from a NDJSON file.
Byte-encoded NDJSON string.
primary_key (optional):
The primary-key used in index. Ignored if already set up.
Expand All @@ -575,24 +575,24 @@ def add_documents_ndjson(

def add_documents_raw(
self,
str_documents: str,
str_documents: bytes,
primary_key: Optional[str] = None,
content_type: Optional[str] = None,
csv_delimiter: Optional[str] = None,
*,
serializer: Optional[Type[JSONEncoder]] = None,
) -> TaskInfo:
"""Add string documents to the index.
"""Add documents to the index from a byte-encoded string.
Parameters
----------
str_documents:
String of document.
Byte-encoded string.
content_type:
The content MIME type: 'application/json', 'application/x-dnjson', or 'text/csv'.
primary_key (optional):
The primary-key used in index. Ignored if already set up.
type:
The type of document. Type available: 'csv', 'json', 'jsonl'.
csv_delimiter:
csv_delimiter (optional):
One ASCII character used to customize the delimiter for CSV.
Note: The csv delimiter can only be used with the Content-Type text/csv.
serializer (optional):
Expand Down

0 comments on commit 372c082

Please # to comment.