Skip to content

Commit b09b6b1

Browse files
committed
Implement user dictionary methods
1 parent c6f7f40 commit b09b6b1

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

meilisearch/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Paths:
3333
dumps = "dumps"
3434
pagination = "pagination"
3535
faceting = "faceting"
36+
dictionary = "dictionary"
3637
swap = "swap-indexes"
3738

3839
def __init__(

meilisearch/index.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,66 @@ def reset_faceting_settings(self) -> TaskInfo:
15771577

15781578
return TaskInfo(**task)
15791579

1580+
# USER DICTIONARY SUB-ROUTES
1581+
1582+
def get_dictionary(self) -> List[str]:
1583+
"""Get the dictionary entries of the index.
1584+
1585+
Returns
1586+
-------
1587+
settings:
1588+
List containing the dictionary entries of the index.
1589+
1590+
Raises
1591+
------
1592+
MeilisearchApiError
1593+
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
1594+
"""
1595+
return self.http.get(self.__settings_url_for(self.config.paths.dictionary))
1596+
1597+
def update_dictionary(self, body: Union[List[str], None]) -> TaskInfo:
1598+
"""Update the dictionary of the index.
1599+
1600+
Parameters
1601+
----------
1602+
body:
1603+
List of the new dictionary entries.
1604+
1605+
Returns
1606+
-------
1607+
task_info:
1608+
TaskInfo instance containing information about a task to track the progress of an asynchronous process.
1609+
https://www.meilisearch.com/docs/reference/api/tasks#get-one-task
1610+
1611+
Raises
1612+
------
1613+
MeilisearchApiError
1614+
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
1615+
"""
1616+
task = self.http.put(self.__settings_url_for(self.config.paths.dictionary), body)
1617+
1618+
return TaskInfo(**task)
1619+
1620+
def reset_dictionary(self) -> TaskInfo:
1621+
"""Clear all entries in dictionary
1622+
1623+
Returns
1624+
-------
1625+
task_info:
1626+
TaskInfo instance containing information about a task to track the progress of an asynchronous process.
1627+
https://www.meilisearch.com/docs/reference/api/tasks#get-one-task
1628+
1629+
Raises
1630+
------
1631+
MeilisearchApiError
1632+
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
1633+
"""
1634+
task = self.http.delete(
1635+
self.__settings_url_for(self.config.paths.dictionary),
1636+
)
1637+
1638+
return TaskInfo(**task)
1639+
15801640
@staticmethod
15811641
def _batch(
15821642
documents: List[Dict[str, Any]], batch_size: int

0 commit comments

Comments
 (0)