|
5 | 5 | from urllib import parse
|
6 | 6 | from warnings import warn
|
7 | 7 |
|
| 8 | +from camel_converter import to_snake |
| 9 | + |
8 | 10 | from meilisearch._httprequests import HttpRequests
|
9 | 11 | from meilisearch._utils import iso_to_date_time
|
10 | 12 | from meilisearch.config import Config
|
|
17 | 19 | IndexStats,
|
18 | 20 | OpenAiEmbedder,
|
19 | 21 | Pagination,
|
| 22 | + ProximityPrecision, |
20 | 23 | TypoTolerance,
|
21 | 24 | UserProvidedEmbedder,
|
22 | 25 | )
|
23 | 26 | from meilisearch.models.task import Task, TaskInfo, TaskResults
|
24 | 27 | from meilisearch.task import TaskHandler
|
25 | 28 |
|
26 | 29 |
|
27 |
| -# pylint: disable=too-many-public-methods |
| 30 | +# pylint: disable=too-many-public-methods, too-many-lines |
28 | 31 | class Index:
|
29 | 32 | """
|
30 | 33 | Indexes routes wrapper.
|
@@ -1917,6 +1920,67 @@ def reset_search_cutoff_ms(self) -> TaskInfo:
|
1917 | 1920 |
|
1918 | 1921 | return TaskInfo(**task)
|
1919 | 1922 |
|
| 1923 | + # PROXIMITY PRECISION SETTINGS |
| 1924 | + |
| 1925 | + def get_proximity_precision(self) -> ProximityPrecision: |
| 1926 | + """Get the proximity_precision of the index. |
| 1927 | +
|
| 1928 | + Returns |
| 1929 | + ------- |
| 1930 | + settings: |
| 1931 | + proximity_precision of the index. |
| 1932 | +
|
| 1933 | + Raises |
| 1934 | + ------ |
| 1935 | + MeilisearchApiError |
| 1936 | + 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 |
| 1937 | + """ |
| 1938 | + response = self.http.get(self.__settings_url_for(self.config.paths.proximity_precision)) |
| 1939 | + return ProximityPrecision[to_snake(response).upper()] |
| 1940 | + |
| 1941 | + def update_proximity_precision(self, body: Union[ProximityPrecision, None]) -> TaskInfo: |
| 1942 | + """Update the proximity_precision of the index. |
| 1943 | +
|
| 1944 | + Parameters |
| 1945 | + ---------- |
| 1946 | + body: |
| 1947 | + proximity_precision |
| 1948 | +
|
| 1949 | + Returns |
| 1950 | + ------- |
| 1951 | + task_info: |
| 1952 | + TaskInfo instance containing information about a task to track the progress of an asynchronous process. |
| 1953 | + https://www.meilisearch.com/docs/reference/api/tasks#get-one-task |
| 1954 | +
|
| 1955 | + Raises |
| 1956 | + ------ |
| 1957 | + MeilisearchApiError |
| 1958 | + 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 |
| 1959 | + """ |
| 1960 | + task = self.http.put(self.__settings_url_for(self.config.paths.proximity_precision), body) |
| 1961 | + |
| 1962 | + return TaskInfo(**task) |
| 1963 | + |
| 1964 | + def reset_proximity_precision(self) -> TaskInfo: |
| 1965 | + """Reset the proximity_precision of the index |
| 1966 | +
|
| 1967 | + Returns |
| 1968 | + ------- |
| 1969 | + task_info: |
| 1970 | + TaskInfo instance containing information about a task to track the progress of an asynchronous process. |
| 1971 | + https://www.meilisearch.com/docs/reference/api/tasks#get-one-task |
| 1972 | +
|
| 1973 | + Raises |
| 1974 | + ------ |
| 1975 | + MeilisearchApiError |
| 1976 | + 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 |
| 1977 | + """ |
| 1978 | + task = self.http.delete( |
| 1979 | + self.__settings_url_for(self.config.paths.proximity_precision), |
| 1980 | + ) |
| 1981 | + |
| 1982 | + return TaskInfo(**task) |
| 1983 | + |
1920 | 1984 | @staticmethod
|
1921 | 1985 | def _batch(
|
1922 | 1986 | documents: Sequence[Mapping[str, Any]], batch_size: int
|
|
0 commit comments