25
25
from meilisearch .errors import version_error_hint_message
26
26
from meilisearch .models .document import Document , DocumentsResults
27
27
from meilisearch .models .embedders import (
28
+ CompositeEmbedder ,
28
29
Embedders ,
29
30
EmbedderType ,
30
31
HuggingFaceEmbedder ,
38
39
IndexStats ,
39
40
LocalizedAttributes ,
40
41
Pagination ,
42
+ PrefixSearch ,
41
43
ProximityPrecision ,
42
44
TypoTolerance ,
43
45
)
@@ -977,6 +979,8 @@ def get_settings(self) -> Dict[str, Any]:
977
979
embedders [k ] = HuggingFaceEmbedder (** v )
978
980
elif v .get ("source" ) == "rest" :
979
981
embedders [k ] = RestEmbedder (** v )
982
+ elif v .get ("source" ) == "composite" :
983
+ embedders [k ] = CompositeEmbedder (** v )
980
984
else :
981
985
embedders [k ] = UserProvidedEmbedder (** v )
982
986
@@ -1662,6 +1666,57 @@ def reset_pagination_settings(self) -> TaskInfo:
1662
1666
1663
1667
return TaskInfo (** task )
1664
1668
1669
+ def get_facet_search_settings (self ) -> bool :
1670
+ """Get the facet search settings of an index.
1671
+
1672
+ Returns
1673
+ -------
1674
+ bool:
1675
+ True if facet search is enabled, False if disabled.
1676
+ Raises
1677
+ ------
1678
+ MeilisearchApiError
1679
+ 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
1680
+ """
1681
+
1682
+ return self .http .get (self .__settings_url_for (self .config .paths .facet_search ))
1683
+
1684
+ def update_facet_search_settings (self , body : Union [bool , None ]) -> TaskInfo :
1685
+ """Update the facet search settings of the index.
1686
+
1687
+ Parameters
1688
+ ----------
1689
+ body: bool
1690
+ True to enable facet search, False to disable it.
1691
+
1692
+ Returns
1693
+ -------
1694
+ task_info:
1695
+ TaskInfo instance containing information about a task to track the progress of an asynchronous process.
1696
+ https://www.meilisearch.com/docs/reference/api/tasks#get-one-task
1697
+
1698
+ Raises
1699
+ ------
1700
+ MeilisearchApiError
1701
+ 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
1702
+ """
1703
+ task = self .http .put (self .__settings_url_for (self .config .paths .facet_search ), body = body )
1704
+
1705
+ return TaskInfo (** task )
1706
+
1707
+ def reset_facet_search_settings (self ) -> TaskInfo :
1708
+ """Reset facet search settings of the index to default values.
1709
+
1710
+ Returns
1711
+ -------
1712
+ task_info:
1713
+ TaskInfo instance containing information about a task to track the progress of an asynchronous process.
1714
+ https://www.meilisearch.com/docs/reference/api/tasks
1715
+ """
1716
+ task = self .http .delete (self .__settings_url_for (self .config .paths .facet_search ))
1717
+
1718
+ return TaskInfo (** task )
1719
+
1665
1720
def get_faceting_settings (self ) -> Faceting :
1666
1721
"""Get the faceting settings of an index.
1667
1722
@@ -1675,7 +1730,6 @@ def get_faceting_settings(self) -> Faceting:
1675
1730
MeilisearchApiError
1676
1731
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
1677
1732
"""
1678
-
1679
1733
faceting = self .http .get (self .__settings_url_for (self .config .paths .faceting ))
1680
1734
1681
1735
return Faceting (** faceting )
@@ -1934,6 +1988,8 @@ def get_embedders(self) -> Embedders | None:
1934
1988
embedders [k ] = OllamaEmbedder (** v )
1935
1989
elif source == "rest" :
1936
1990
embedders [k ] = RestEmbedder (** v )
1991
+ elif source == "composite" :
1992
+ embedders [k ] = CompositeEmbedder (** v )
1937
1993
elif source == "userProvided" :
1938
1994
embedders [k ] = UserProvidedEmbedder (** v )
1939
1995
else :
@@ -1977,6 +2033,8 @@ def update_embedders(self, body: Union[MutableMapping[str, Any], None]) -> TaskI
1977
2033
embedders [k ] = OllamaEmbedder (** v )
1978
2034
elif source == "rest" :
1979
2035
embedders [k ] = RestEmbedder (** v )
2036
+ elif source == "composite" :
2037
+ embedders [k ] = CompositeEmbedder (** v )
1980
2038
elif source == "userProvided" :
1981
2039
embedders [k ] = UserProvidedEmbedder (** v )
1982
2040
else :
@@ -2071,6 +2129,58 @@ def reset_search_cutoff_ms(self) -> TaskInfo:
2071
2129
2072
2130
return TaskInfo (** task )
2073
2131
2132
+ # PREFIX SEARCH
2133
+
2134
+ def get_prefix_search (self ) -> PrefixSearch :
2135
+ """Get the prefix search settings of an index.
2136
+
2137
+ Returns
2138
+ -------
2139
+ settings:
2140
+ The prefix search settings of the index.
2141
+
2142
+ Raises
2143
+ ------
2144
+ MeilisearchApiError
2145
+ 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
2146
+ """
2147
+ prefix_search = self .http .get (self .__settings_url_for (self .config .paths .prefix_search ))
2148
+
2149
+ return PrefixSearch [to_snake (prefix_search ).upper ()]
2150
+
2151
+ def update_prefix_search (self , body : Union [PrefixSearch , None ]) -> TaskInfo :
2152
+ """Update the prefix search settings of the index.
2153
+
2154
+ Parameters
2155
+ ----------
2156
+ body:
2157
+ Prefix search settings
2158
+
2159
+ Returns
2160
+ -------
2161
+ task_info:
2162
+ TaskInfo instance containing information about a task to track the progress of an asynchronous process.
2163
+ https://www.meilisearch.com/docs/reference/api/tasks
2164
+ """
2165
+ task = self .http .put (self .__settings_url_for (self .config .paths .prefix_search ), body )
2166
+
2167
+ return TaskInfo (** task )
2168
+
2169
+ def reset_prefix_search (self ) -> TaskInfo :
2170
+ """Reset the prefix search settings of the index
2171
+
2172
+ Returns
2173
+ -------
2174
+ task_info:
2175
+ TaskInfo instance containing information about a task to track the progress of an asynchronous process.
2176
+ https://www.meilisearch.com/docs/reference/api/tasks
2177
+ """
2178
+ task = self .http .delete (
2179
+ self .__settings_url_for (self .config .paths .prefix_search ),
2180
+ )
2181
+
2182
+ return TaskInfo (** task )
2183
+
2074
2184
# PROXIMITY PRECISION SETTINGS
2075
2185
2076
2186
def get_proximity_precision (self ) -> ProximityPrecision :
0 commit comments