Skip to content

Commit 3b6f06c

Browse files
authored
Merge pull request #660 from sanders41/meilisearch-1.4.0
Update for Meilisearch v1.4.0
2 parents 4f18d94 + 6242947 commit 3b6f06c

File tree

3 files changed

+346
-0
lines changed

3 files changed

+346
-0
lines changed

meilisearch_python_async/index.py

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,10 @@ async def get_sortable_attributes(self) -> list[str]:
23322332
async def update_sortable_attributes(self, sortable_attributes: list[str]) -> TaskInfo:
23332333
"""Get sortable attributes of the Index.
23342334
2335+
Args:
2336+
2337+
sortable_attributes: List of attributes for searching.
2338+
23352339
Returns:
23362340
23372341
The details of the task status.
@@ -2404,6 +2408,10 @@ async def get_typo_tolerance(self) -> TypoTolerance:
24042408
async def update_typo_tolerance(self, typo_tolerance: TypoTolerance) -> TaskInfo:
24052409
"""Update typo tolerance.
24062410
2411+
Args:
2412+
2413+
typo_tolerance: Typo tolerance settings.
2414+
24072415
Returns:
24082416
24092417
Task to track the action.
@@ -2481,6 +2489,10 @@ async def get_faceting(self) -> Faceting:
24812489
async def update_faceting(self, faceting: Faceting) -> TaskInfo:
24822490
"""Partially update the faceting settings for an index.
24832491
2492+
Args:
2493+
2494+
faceting: Faceting values.
2495+
24842496
Returns:
24852497
24862498
Task to track the action.
@@ -2557,6 +2569,10 @@ async def get_pagination(self) -> Pagination:
25572569
async def update_pagination(self, settings: Pagination) -> TaskInfo:
25582570
"""Partially update the pagination settings for an index.
25592571
2572+
Args:
2573+
2574+
settings: settings for pagination.
2575+
25602576
Returns:
25612577
25622578
Task to track the action.
@@ -2607,6 +2623,234 @@ async def reset_pagination(self) -> TaskInfo:
26072623

26082624
return TaskInfo(**response.json())
26092625

2626+
async def get_separator_tokens(self) -> list[str]:
2627+
"""Get separator token settings for the index.
2628+
2629+
Returns:
2630+
2631+
Separator tokens for the index.
2632+
2633+
Raises:
2634+
2635+
MeilisearchCommunicationError: If there was an error communicating with the server.
2636+
MeilisearchApiError: If the Meilisearch API returned an error.
2637+
2638+
Examples:
2639+
2640+
>>> from meilisearch_async_client import Client
2641+
>>> async with Client("http://localhost.com", "masterKey") as client:
2642+
>>> index = client.index("movies")
2643+
>>> separator_token_settings = await index.get_separator_tokens()
2644+
"""
2645+
url = f"{self._settings_url}/separator-tokens"
2646+
response = await self._http_requests.get(url)
2647+
2648+
return response.json()
2649+
2650+
async def update_separator_tokens(self, separator_tokens: list[str]) -> TaskInfo:
2651+
"""Update the separator tokens settings for an index.
2652+
2653+
Args:
2654+
2655+
separator_tokens: List of separator tokens.
2656+
2657+
Returns:
2658+
2659+
Task to track the action.
2660+
2661+
Raises:
2662+
2663+
MeilisearchCommunicationError: If there was an error communicating with the server.
2664+
MeilisearchApiError: If the Meilisearch API returned an error.
2665+
2666+
Examples:
2667+
2668+
>>> from meilisearch_python_async import Client
2669+
>>> async with Client("http://localhost.com", "masterKey") as client:
2670+
>>> index = client.index("movies")
2671+
>>> await index.update_separator_tokens(separator_tokenes=["|", "/")
2672+
"""
2673+
url = f"{self._settings_url}/separator-tokens"
2674+
response = await self._http_requests.put(url, separator_tokens)
2675+
2676+
return TaskInfo(**response.json())
2677+
2678+
async def reset_separator_tokens(self) -> TaskInfo:
2679+
"""Reset an index's separator tokens settings to the default value.
2680+
2681+
Returns:
2682+
2683+
The details of the task status.
2684+
2685+
Raises:
2686+
2687+
MeilisearchCommunicationError: If there was an error communicating with the server.
2688+
MeilisearchApiError: If the Meilisearch API returned an error.
2689+
2690+
Examples:
2691+
2692+
>>> from meilisearch_async_client import Client
2693+
>>> async with Client("http://localhost.com", "masterKey") as client:
2694+
>>> index = client.index("movies")
2695+
>>> await index.reset_separator_tokens()
2696+
"""
2697+
url = f"{self._settings_url}/separator-tokens"
2698+
response = await self._http_requests.delete(url)
2699+
2700+
return TaskInfo(**response.json())
2701+
2702+
async def get_non_separator_tokens(self) -> list[str]:
2703+
"""Get non-separator token settings for the index.
2704+
2705+
Returns:
2706+
2707+
Non-separator tokens for the index.
2708+
2709+
Raises:
2710+
2711+
MeilisearchCommunicationError: If there was an error communicating with the server.
2712+
MeilisearchApiError: If the Meilisearch API returned an error.
2713+
2714+
Examples:
2715+
2716+
>>> from meilisearch_async_client import Client
2717+
>>> async with Client("http://localhost.com", "masterKey") as client:
2718+
>>> index = client.index("movies")
2719+
>>> non_separator_token_settings = await index.get_non_separator_tokens()
2720+
"""
2721+
url = f"{self._settings_url}/non-separator-tokens"
2722+
response = await self._http_requests.get(url)
2723+
2724+
return response.json()
2725+
2726+
async def update_non_separator_tokens(self, non_separator_tokens: list[str]) -> TaskInfo:
2727+
"""Update the non-separator tokens settings for an index.
2728+
2729+
Args:
2730+
2731+
non_separator_tokens: List of non-separator tokens.
2732+
2733+
Returns:
2734+
2735+
Task to track the action.
2736+
2737+
Raises:
2738+
2739+
MeilisearchCommunicationError: If there was an error communicating with the server.
2740+
MeilisearchApiError: If the Meilisearch API returned an error.
2741+
2742+
Examples:
2743+
2744+
>>> from meilisearch_python_async import Client
2745+
>>> async with Client("http://localhost.com", "masterKey") as client:
2746+
>>> index = client.index("movies")
2747+
>>> await index.update_non_separator_tokens(non_separator_tokens=["@", "#")
2748+
"""
2749+
url = f"{self._settings_url}/non-separator-tokens"
2750+
response = await self._http_requests.put(url, non_separator_tokens)
2751+
2752+
return TaskInfo(**response.json())
2753+
2754+
async def reset_non_separator_tokens(self) -> TaskInfo:
2755+
"""Reset an index's non-separator tokens settings to the default value.
2756+
2757+
Returns:
2758+
2759+
The details of the task status.
2760+
2761+
Raises:
2762+
2763+
MeilisearchCommunicationError: If there was an error communicating with the server.
2764+
MeilisearchApiError: If the Meilisearch API returned an error.
2765+
2766+
Examples:
2767+
2768+
>>> from meilisearch_async_client import Client
2769+
>>> async with Client("http://localhost.com", "masterKey") as client:
2770+
>>> index = client.index("movies")
2771+
>>> await index.reset_non_separator_tokens()
2772+
"""
2773+
url = f"{self._settings_url}/non-separator-tokens"
2774+
response = await self._http_requests.delete(url)
2775+
2776+
return TaskInfo(**response.json())
2777+
2778+
async def get_word_dictionary(self) -> list[str]:
2779+
"""Get word dictionary settings for the index.
2780+
2781+
Returns:
2782+
2783+
Word dictionary for the index.
2784+
2785+
Raises:
2786+
2787+
MeilisearchCommunicationError: If there was an error communicating with the server.
2788+
MeilisearchApiError: If the Meilisearch API returned an error.
2789+
2790+
Examples:
2791+
2792+
>>> from meilisearch_async_client import Client
2793+
>>> async with Client("http://localhost.com", "masterKey") as client:
2794+
>>> index = client.index("movies")
2795+
>>> word_dictionary = await index.get_word_dictionary()
2796+
"""
2797+
url = f"{self._settings_url}/dictionary"
2798+
response = await self._http_requests.get(url)
2799+
2800+
return response.json()
2801+
2802+
async def update_word_dictionary(self, dictionary: list[str]) -> TaskInfo:
2803+
"""Update the word dictionary settings for an index.
2804+
2805+
Args:
2806+
2807+
dictionary: List of dictionary values.
2808+
2809+
Returns:
2810+
2811+
Task to track the action.
2812+
2813+
Raises:
2814+
2815+
MeilisearchCommunicationError: If there was an error communicating with the server.
2816+
MeilisearchApiError: If the Meilisearch API returned an error.
2817+
2818+
Examples:
2819+
2820+
>>> from meilisearch_python_async import Client
2821+
>>> async with Client("http://localhost.com", "masterKey") as client:
2822+
>>> index = client.index("movies")
2823+
>>> await index.update_word_dictionary(dictionary=["S.O.S", "S.O")
2824+
"""
2825+
url = f"{self._settings_url}/dictionary"
2826+
response = await self._http_requests.put(url, dictionary)
2827+
2828+
return TaskInfo(**response.json())
2829+
2830+
async def reset_word_dictionary(self) -> TaskInfo:
2831+
"""Reset an index's word dictionary settings to the default value.
2832+
2833+
Returns:
2834+
2835+
The details of the task status.
2836+
2837+
Raises:
2838+
2839+
MeilisearchCommunicationError: If there was an error communicating with the server.
2840+
MeilisearchApiError: If the Meilisearch API returned an error.
2841+
2842+
Examples:
2843+
2844+
>>> from meilisearch_async_client import Client
2845+
>>> async with Client("http://localhost.com", "masterKey") as client:
2846+
>>> index = client.index("movies")
2847+
>>> await index.reset_word_dictionary()
2848+
"""
2849+
url = f"{self._settings_url}/dictionary"
2850+
response = await self._http_requests.delete(url)
2851+
2852+
return TaskInfo(**response.json())
2853+
26102854

26112855
def _batch(documents: list[dict], batch_size: int) -> Generator[list[dict], None, None]:
26122856
total_len = len(documents)

meilisearch_python_async/models/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ class MeilisearchSettings(CamelBase):
6767
typo_tolerance: Optional[TypoTolerance] = None
6868
faceting: Optional[Faceting] = None
6969
pagination: Optional[Pagination] = None
70+
separator_tokens: Optional[List[str]] = None
71+
non_separator_tokens: Optional[List[str]] = None
72+
dictionary: Optional[List[str]] = None

0 commit comments

Comments
 (0)