Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ getting_started_typo_tolerance: |-
'oneTypo': 4
}
})
get_typo_tolerance_1:
get_typo_tolerance_1: |-
client.index('books').get_typo_tolerance()
update_typo_tolerance_1: |-
client.index('books').update_typo_tolerance({
Expand Down Expand Up @@ -701,3 +701,5 @@ update_dictionary_1: |-
client.index('books').update_dictionary(["J. R. R.", "W. E. B."])
reset_dictionary_1: |-
client.index('books').reset_dictionary()
create_snapshot_1: |-
client.create_snapshot()
18 changes: 18 additions & 0 deletions meilisearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,24 @@ def create_dump(self) -> TaskInfo:

return TaskInfo(**task)

def create_snapshot(self) -> TaskInfo:
"""Trigger the creation of a Meilisearch snapshot.

Returns
-------
task_info:
TaskInfo instance containing information about a task to track the progress of an asynchronous process.
https://www.meilisearch.com/docs/reference/api/tasks#get-one-task

Raises
------
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
"""
task = self.http.post(self.config.paths.snapshots)

return TaskInfo(**task)

def swap_indexes(self, parameters: List[Mapping[str, List[str]]]) -> TaskInfo:
"""Swap two indexes.

Expand Down
1 change: 1 addition & 0 deletions meilisearch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Paths:
sortable_attributes = "sortable-attributes"
typo_tolerance = "typo-tolerance"
dumps = "dumps"
snapshots = "snapshots"
pagination = "pagination"
faceting = "faceting"
dictionary = "dictionary"
Expand Down
11 changes: 11 additions & 0 deletions tests/client/test_clinet_snapshots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# pylint: disable=invalid-name


def test_snapshot_creation(client, index_with_documents):
"""Tests the creation of a Meilisearch snapshot."""
index_with_documents("indexUID-snapshot-creation")
snapshot = client.create_snapshot()
client.wait_for_task(snapshot.task_uid)
snapshot_status = client.get_task(snapshot.task_uid)
assert snapshot_status.status == "succeeded"
assert snapshot_status.type == "snapshotCreation"