Skip to content

Commit f988c0b

Browse files
committed
Add (non)separator token sub routes
1 parent cfe5bb0 commit f988c0b

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

meilisearch/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class Paths:
3434
pagination = "pagination"
3535
faceting = "faceting"
3636
dictionary = "dictionary"
37+
separator_tokens = "separator-tokens"
38+
non_separator_tokens = "non-separator-tokens"
3739
swap = "swap-indexes"
3840

3941
def __init__(

meilisearch/index.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,124 @@ def reset_dictionary(self) -> TaskInfo:
16371637

16381638
return TaskInfo(**task)
16391639

1640+
# TEXT SEPARATOR SUB-ROUTES
1641+
1642+
def get_separator_tokens(self) -> List[str]:
1643+
"""Get the additional text separator tokens set on this index.
1644+
1645+
Returns
1646+
-------
1647+
settings:
1648+
List containing the separator tokens of the index.
1649+
1650+
Raises
1651+
------
1652+
MeilisearchApiError
1653+
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
1654+
"""
1655+
return self.http.get(self.__settings_url_for(self.config.paths.separator_tokens))
1656+
1657+
def get_non_separator_tokens(self) -> List[str]:
1658+
"""Get the list of disabled text separator tokens on this index.
1659+
1660+
Returns
1661+
-------
1662+
settings:
1663+
List containing the disabled separator tokens of the index.
1664+
1665+
Raises
1666+
------
1667+
MeilisearchApiError
1668+
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
1669+
"""
1670+
return self.http.get(self.__settings_url_for(self.config.paths.non_separator_tokens))
1671+
1672+
def update_separator_tokens(self, body: List[str]) -> TaskInfo:
1673+
"""Update the additional separator tokens of the index.
1674+
1675+
Parameters
1676+
----------
1677+
body:
1678+
List of the new separator tokens.
1679+
1680+
Returns
1681+
-------
1682+
task_info:
1683+
TaskInfo instance containing information about a task to track the progress of an asynchronous process.
1684+
https://www.meilisearch.com/docs/reference/api/tasks#get-one-task
1685+
1686+
Raises
1687+
------
1688+
MeilisearchApiError
1689+
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
1690+
"""
1691+
task = self.http.put(self.__settings_url_for(self.config.paths.separator_tokens), body)
1692+
1693+
return TaskInfo(**task)
1694+
1695+
def update_non_separator_tokens(self, body: List[str]) -> TaskInfo:
1696+
"""Update the disabled separator tokens of the index.
1697+
1698+
Parameters
1699+
----------
1700+
body:
1701+
List of the newly disabled separator tokens.
1702+
1703+
Returns
1704+
-------
1705+
task_info:
1706+
TaskInfo instance containing information about a task to track the progress of an asynchronous process.
1707+
https://www.meilisearch.com/docs/reference/api/tasks#get-one-task
1708+
1709+
Raises
1710+
------
1711+
MeilisearchApiError
1712+
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
1713+
"""
1714+
task = self.http.put(self.__settings_url_for(self.config.paths.non_separator_tokens), body)
1715+
1716+
return TaskInfo(**task)
1717+
1718+
def reset_separator_tokens(self) -> TaskInfo:
1719+
"""Clear all additional separator tokens
1720+
1721+
Returns
1722+
-------
1723+
task_info:
1724+
TaskInfo instance containing information about a task to track the progress of an asynchronous process.
1725+
https://www.meilisearch.com/docs/reference/api/tasks#get-one-task
1726+
1727+
Raises
1728+
------
1729+
MeilisearchApiError
1730+
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
1731+
"""
1732+
task = self.http.delete(
1733+
self.__settings_url_for(self.config.paths.separator_tokens),
1734+
)
1735+
1736+
return TaskInfo(**task)
1737+
1738+
def reset_non_separator_tokens(self) -> TaskInfo:
1739+
"""Clear all disabled separator tokens
1740+
1741+
Returns
1742+
-------
1743+
task_info:
1744+
TaskInfo instance containing information about a task to track the progress of an asynchronous process.
1745+
https://www.meilisearch.com/docs/reference/api/tasks#get-one-task
1746+
1747+
Raises
1748+
------
1749+
MeilisearchApiError
1750+
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
1751+
"""
1752+
task = self.http.delete(
1753+
self.__settings_url_for(self.config.paths.non_separator_tokens),
1754+
)
1755+
1756+
return TaskInfo(**task)
1757+
16401758
@staticmethod
16411759
def _batch(
16421760
documents: List[Dict[str, Any]], batch_size: int

0 commit comments

Comments
 (0)