From c1d8eab5b4aed71cb3362e8c816426647e3e28db Mon Sep 17 00:00:00 2001 From: Clementine Urquizar Date: Wed, 2 Dec 2020 18:43:01 +0100 Subject: [PATCH 1/2] Update docs comments --- meilisearch/client.py | 111 ++-- meilisearch/config.py | 6 +- meilisearch/errors.py | 2 +- meilisearch/index.py | 573 ++++++++++++------ meilisearch/tests/client/test_client.py | 6 +- meilisearch/tests/client/test_client_dumps.py | 6 +- .../client/test_client_health_meilisearch.py | 2 +- .../client/test_client_key_meilisearch.py | 2 +- .../client/test_client_stats_meilisearch.py | 2 +- .../client/test_client_version_meilisearch.py | 2 +- meilisearch/tests/conftest.py | 17 +- meilisearch/tests/index/test_index.py | 28 +- .../index/test_index_document_meilisearch.py | 25 +- .../index/test_index_search_meilisearch.py | 24 +- .../index/test_index_stats_meilisearch.py | 2 +- .../index/test_index_update_meilisearch.py | 8 +- .../test_index_wait_for_pending_update.py | 8 +- meilisearch/tests/settings/test_settings.py | 6 +- ...ngs_attributes_for_faceting_meilisearch.py | 6 +- ...ttings_displayed_attributes_meilisearch.py | 6 +- ...settings_distinct_attribute_meilisearch.py | 6 +- ...test_settings_ranking_rules_meilisearch.py | 6 +- ...tings_searchable_attributes_meilisearch.py | 6 +- .../test_settings_stop_words_meilisearch.py | 6 +- .../test_settings_synonyms_meilisearch.py | 6 +- 25 files changed, 552 insertions(+), 320 deletions(-) diff --git a/meilisearch/client.py b/meilisearch/client.py index c7ac574d..d97e2384 100644 --- a/meilisearch/client.py +++ b/meilisearch/client.py @@ -32,32 +32,34 @@ def create_index(self, uid, options=None): Parameters ---------- uid: str - UID of the index - options: dict, optional - Options passed during index creation (ex: primaryKey) + UID of the index. + options (optional): dict + Options passed during index creation (ex: primaryKey). Returns ------- index : Index - an instance of Index containing the information of the newly created index + An instance of Index containing the information of the newly created index. + Raises ------ - HTTPError - In case of any other error found here https://docs.meilisearch.com/references/#errors-status-code + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return Index.create(self.config, uid, options) def get_indexes(self): """Get all indexes. - Raises - ------ - HTTPError - In case of any error found here https://docs.meilisearch.com/references/#errors-status-code Returns ------- - list - List of indexes in dictionnary format. (e.g [{ 'uid': 'movies' 'primaryKey': 'objectID' }]) + indexes: list + List of indexes in dictionary format. (e.g [{ 'uid': 'movies' 'primaryKey': 'objectID' }]) + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get(self.config.paths.index) @@ -70,20 +72,21 @@ def get_index(self, uid): uid: str UID of the index. - Raises - ------ - HTTPError - In case of any error found here https://docs.meilisearch.com/references/#errors-status-code Returns ------- index : Index An Index instance containing the information of the fetched index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return Index(self.config, uid).fetch_info() def index(self, uid): - """Create a local reference to an index identified by `uid`, without doing an HTTP call. - Calling this method doesn't create an index by itself, but grants access to all the other methods in the Index class. + """Create a local reference to an index identified by UID, without doing an HTTP call. + Calling this method doesn't create an index in the MeiliSearch instance, but grants access to all the other methods in the Index class. Parameters ---------- @@ -100,23 +103,24 @@ def index(self, uid): raise Exception('The index UID should not be None') def get_or_create_index(self, uid, options=None): - """Retrieve an index in MeiliSearch, or create it if it doesn't exist yet. + """Get an index, or create it if it doesn't exist. Parameters ---------- uid: str UID of the index - options: dict, optional + options (optional): dict Options passed during index creation (ex: primaryKey) Returns ------- index : Index - An Index instance containing the information of the retrieved or newly created index. + An instance of Index containing the information of the retrieved or newly created index. + Raises ------ MeiliSearchApiError - In case of any other error found here https://docs.meilisearch.com/references/#errors-status-code + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ try: index_instance = self.get_index(uid) @@ -131,35 +135,46 @@ def get_all_stats(self): Get information about database size and all indexes https://docs.meilisearch.com/references/stats.html + Returns - ---------- + ------- stats: `dict` - Dictionnary containing stats about your MeiliSearch instance + Dictionary containing stats about your MeiliSearch instance. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get(self.config.paths.stat) def health(self): - """Get health of MeiliSearch + """Get health of the MeiliSearch server. `204` HTTP status response when MeiliSearch is healthy. Raises - ---------- - HTTPError - If MeiliSearch is not healthy + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get(self.config.paths.health) def get_keys(self): - """Get all keys created + """Get all keys. - Get list of all the keys that were created and all their related information. + Get list of all the keys. Returns - ---------- + ------- keys: list List of keys and their information. https://docs.meilisearch.com/references/keys.html#get-keys + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get(self.config.paths.keys) @@ -167,9 +182,14 @@ def get_version(self): """Get version MeiliSearch Returns - ---------- + ------- version: dict Information about the version of MeiliSearch. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get(self.config.paths.version) @@ -177,36 +197,51 @@ def version(self): """Alias for get_version Returns - ---------- + ------- version: dict Information about the version of MeiliSearch. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.get_version() def create_dump(self): - """Triggers the creation of a MeiliSearch dump + """Trigger the creation of a MeiliSearch dump. Returns - ---------- + ------- Dump: dict Information about the dump. https://docs.meilisearch.com/references/dump.html#create-a-dump + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post(self.config.paths.dumps) def get_dump_status(self, uid): - """Retrieves the status of a MeiliSearch dump creation + """Retrieve the status of a MeiliSearch dump creation. Parameters ---------- uid: str - UID of the dump + UID of the dump. Returns - ---------- + ------- Dump status: dict Information about the dump status. https://docs.meilisearch.com/references/dump.html#get-dump-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( self.config.paths.dumps + '/' + str(uid) + '/status' diff --git a/meilisearch/config.py b/meilisearch/config.py index 0be99a8c..4c2e8bf8 100644 --- a/meilisearch/config.py +++ b/meilisearch/config.py @@ -1,6 +1,6 @@ class Config: """ - A client's credentials and configuration parameters + Client's credentials and configuration parameters """ class Paths(): @@ -27,9 +27,9 @@ def __init__(self, url, api_key=None): """ Parameters ---------- - url : str + url: str The url to the MeiliSearch API (ex: http://localhost:7700) - api_key : str + api_key (optional): str The optional API key to access MeiliSearch """ diff --git a/meilisearch/errors.py b/meilisearch/errors.py index c11a457a..7ce21aa7 100644 --- a/meilisearch/errors.py +++ b/meilisearch/errors.py @@ -27,7 +27,7 @@ def __str__(self): return f'MeiliSearchApiError. Error code: {self.error_code}. Error message: {self.message}. Error documentation: {self.error_link}' class MeiliSearchCommunicationError(MeiliSearchError): - """Error connecting to MeiliSearch""" + """Error when connecting to MeiliSearch""" def __str__(self): return f'MeiliSearchCommunicationError, {self.message}' diff --git a/meilisearch/index.py b/meilisearch/index.py index e89a8221..1346c346 100644 --- a/meilisearch/index.py +++ b/meilisearch/index.py @@ -6,7 +6,7 @@ # pylint: disable=too-many-public-methods class Index(): """ - Indexes routes wrapper + Indexes routes wrapper. Index class gives access to all indexes routes and child routes (herited). https://docs.meilisearch.com/references/indexes.html @@ -22,10 +22,10 @@ def __init__(self, config, uid, primary_key=None): Parameters ---------- config : dict - Config object containing MeiliSearch configuration data, such as url and API Key. + Config object containing permission and location of MeiliSearch. uid: str - UID of the index in which further actions will be performed. - primary_key: str, optional + UID of the index on which to perform the index actions. + primary_key (optional): str Primary-key of the index. """ self.config = config @@ -34,18 +34,17 @@ def __init__(self, config, uid, primary_key=None): self.primary_key = primary_key def delete(self): - """Delete an index from meilisearch + """Delete the index. - Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: - https://docs.meilisearch.com/references/updates.html#get-an-update-status + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete('{}/{}'.format(self.config.paths.index, self.uid)) def update(self, **body): - """Update the primary-key of the index. + """Update the index primary-key. Parameters ---------- @@ -57,6 +56,11 @@ def update(self, **body): ------- index: dict Dictionary containing index information. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ payload = {} primary_key = body.get('primaryKey', None) @@ -67,24 +71,34 @@ def update(self, **body): return self def fetch_info(self): - """Fetch the information of the index. + """Fetch the info of the index. Returns ------- - index : Index - An Index instance containing the information of the index. + index: dict + Dictionary containing the index information. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ index_dict = self.http.get('{}/{}'.format(self.config.paths.index, self.uid)) self.primary_key = index_dict['primaryKey'] return self def get_primary_key(self): - """Fetch the primary key of the index. + """Get the primary key. Returns ------- primary_key: str | None String containing the primary key. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.fetch_info().primary_key @@ -97,17 +111,17 @@ def create(cls, config, uid, options=None): uid: str UID of the index. options: dict, optional - Options passed during index creation. - Ex: Index.create('indexUID', { 'primaryKey': 'name' }) + Options passed during index creation (ex: { 'primaryKey': 'name' }). Returns ------- index : Index - An Index instance containing the information of the newly created index. + An instance of Index containing the information of the newly created index. + Raises ------ - HTTPError - In case of any error found here https://docs.meilisearch.com/references/#errors-status-code + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ if options is None: options = {} @@ -116,12 +130,17 @@ def create(cls, config, uid, options=None): return cls(config, index_dict['uid'], index_dict['primaryKey']) def get_all_update_status(self): - """Get all update status from MeiliSearch + """Get all update status Returns - ---------- - update: `list` + ------- + update: list List of all enqueued and processed actions of the index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( '{}/{}/{}'.format( @@ -132,16 +151,22 @@ def get_all_update_status(self): ) def get_update_status(self, update_id): - """Get one update from MeiliSearch + """Get one update status Parameters ---------- update_id: int identifier of the update to retrieve + Returns - ---------- - update: `list` + ------- + update: list List containing the details of the update status. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( '{}/{}/{}/{}'.format( @@ -153,7 +178,7 @@ def get_update_status(self, update_id): ) def wait_for_pending_update(self, update_id, timeout_in_ms=5000, interval_in_ms=50): - """Wait until MeiliSearch processes an update, and get its status + """Wait until MeiliSearch processes an update, and get its status. Parameters ---------- @@ -163,10 +188,16 @@ def wait_for_pending_update(self, update_id, timeout_in_ms=5000, interval_in_ms= time the method should wait before rising a TimeoutError interval_in_ms (optional): int time interval the method should wait (sleep) between requests + Returns - ---------- - update: `dict` + ------- + update: dict Dictionary containing the details of the processed update status. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ start_time = datetime.now() elapsed_time = 0 @@ -180,14 +211,20 @@ def wait_for_pending_update(self, update_id, timeout_in_ms=5000, interval_in_ms= raise TimeoutError def get_stats(self): - """Get stats of an index + """Get stats of the index. Get information about the number of documents, field frequencies, ... https://docs.meilisearch.com/references/stats.html + Returns - ---------- - stats: `dict` - Dictionnary containing stats about the given index. + ------- + stats: dict + Dictionary containing stats about the given index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( '{}/{}/{}'.format( @@ -198,19 +235,25 @@ def get_stats(self): ) def search(self, query, opt_params=None): - """Search in meilisearch + """Search in the index. Parameters ---------- query: str String containing the searched word(s) - opt_params: dict - Dictionnary containing optional query parameters + opt_params (optional): dict + Dictionary containing optional query parameters https://docs.meilisearch.com/references/search.html#search-in-an-index + Returns - ---------- - results: `dict` - Dictionnary with hits, offset, limit, processingTime and initial query + ------- + results: dict + Dictionary with hits, offset, limit, processingTime and initial query + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ if opt_params is None: opt_params = {} @@ -227,16 +270,22 @@ def search(self, query, opt_params=None): ) def get_document(self, document_id): - """Get one document with given document identifier + """Get one document with given document identifier. Parameters ---------- document_id: str Unique identifier of the document. + Returns - ---------- - document: `dict` - Dictionnary containing the documents information + ------- + document: dict + Dictionary containing the documents information. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( '{}/{}/{}/{}'.format( @@ -248,16 +297,22 @@ def get_document(self, document_id): ) def get_documents(self, parameters=None): - """Get a set of documents from the index + """Get a set of documents from the index. Parameters ---------- parameters (optional): dict parameters accepted by the get documents route: https://docs.meilisearch.com/references/documents.html#get-all-documents + Returns - ---------- - document: `dict` - Dictionnary containing the documents information + ------- + document: dict + Dictionary containing the documents information. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ if parameters is None: parameters = {} @@ -271,19 +326,25 @@ def get_documents(self, parameters=None): ) def add_documents(self, documents, primary_key=None): - """Add documents to the index + """Add documents to the index. Parameters ---------- documents: list - List of dics containing each a document, or json string - primary_key: string - The primary-key used in MeiliSearch index. Ignored if already set up. + List of documents. Each document should be a dictionary. + primary_key (optional): string + The primary-key used in index. Ignored if already set up. + Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ if primary_key is None: url = '{}/{}/{}'.format( @@ -301,19 +362,25 @@ def add_documents(self, documents, primary_key=None): return self.http.post(url, documents) def update_documents(self, documents, primary_key=None): - """Update documents in the index + """Update documents in the index. Parameters ---------- documents: list - List of dics containing each a document, or json string - primary_key: string - The primary-key used in MeiliSearch index. Ignored if already set up. + List of documents. Each document should be a dictionary. + primary_key (optional): string + The primary-key used in index. Ignored if already set up + Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ if primary_key is None: url = '{}/{}/{}'.format( @@ -332,17 +399,23 @@ def update_documents(self, documents, primary_key=None): def delete_document(self, document_id): - """Add documents to the index + """Delete one document from the index. Parameters ---------- document_id: str Unique identifier of the document. + Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( '{}/{}/{}/{}'.format( @@ -354,17 +427,23 @@ def delete_document(self, document_id): ) def delete_documents(self, ids): - """Delete multiple documents of the index + """Delete multiple documents from the index. Parameters ---------- list: list List of unique identifiers of documents. + Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( '{}/{}/{}/delete-batch'.format( @@ -376,13 +455,18 @@ def delete_documents(self, ids): ) def delete_all_documents(self): - """Delete all documents of the index + """Delete all documents from the index. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( '{}/{}/{}'.format( @@ -396,14 +480,19 @@ def delete_all_documents(self): # GENERAL SETTINGS ROUTES def get_settings(self): - """Get settings of an index + """Get settings of the index. https://docs.meilisearch.com/references/settings.html Returns - ---------- - settings: `dict` - Dictionnary containing the settings of the index + ------- + settings: dict + Dictionary containing the settings of the index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( '{}/{}/{}'.format( @@ -414,21 +503,27 @@ def get_settings(self): ) def update_settings(self, body): - """Update settings of an index + """Update settings of the index. https://docs.meilisearch.com/references/settings.html#update-settings + Parameters ---------- - body: `dict` - Dictionnary containing the settings of the index + body: dict + Dictionary containing the settings of the index. More information: https://docs.meilisearch.com/references/settings.html#update-settings Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( '{}/{}/{}'.format( @@ -440,15 +535,20 @@ def update_settings(self, body): ) def reset_settings(self): - """Reset settings of an index to default values + """Reset settings of the index to default values. https://docs.meilisearch.com/references/settings.html#reset-settings Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( '{}/{}/{}'.format( @@ -462,12 +562,17 @@ def reset_settings(self): def get_ranking_rules(self): """ - Get ranking rules of an index + Get ranking rules of the index. Returns - ---------- - settings: `list` - List containing the ranking rules of the index + ------- + settings: list + List containing the ranking rules of the index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( self.__settings_url_for(self.config.paths.ranking_rules) @@ -475,18 +580,23 @@ def get_ranking_rules(self): def update_ranking_rules(self, body): """ - Update ranking rules of an index + Update ranking rules of the index. Parameters ---------- - body: `list` - List containing the ranking rules + body: list + List containing the ranking rules. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( self.__settings_url_for(self.config.paths.ranking_rules), @@ -494,13 +604,18 @@ def update_ranking_rules(self, body): ) def reset_ranking_rules(self): - """Reset ranking rules of an index to default values + """Reset ranking rules of the index to default values. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( self.__settings_url_for(self.config.paths.ranking_rules), @@ -511,12 +626,17 @@ def reset_ranking_rules(self): def get_distinct_attribute(self): """ - Get distinct attribute of an index + Get distinct attribute of the index. Returns - ---------- - settings: `str` - String containing the distinct attribute of the index + ------- + settings: str + String containing the distinct attribute of the index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( self.__settings_url_for(self.config.paths.distinct_attribute) @@ -524,18 +644,23 @@ def get_distinct_attribute(self): def update_distinct_attribute(self, body): """ - Update distinct attribute of an index + Update distinct attribute of the index. Parameters ---------- - body: `str` - String containing the distinct attribute + body: str + String containing the distinct attribute. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( self.__settings_url_for(self.config.paths.distinct_attribute), @@ -543,13 +668,18 @@ def update_distinct_attribute(self, body): ) def reset_distinct_attribute(self): - """Reset distinct attribute of an index to default values + """Reset distinct attribute of the index to default values. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( self.__settings_url_for(self.config.paths.distinct_attribute), @@ -559,12 +689,17 @@ def reset_distinct_attribute(self): def get_searchable_attributes(self): """ - Get searchable attributes of an index + Get searchable attributes of the index. Returns - ---------- - settings: `list` - List containing the searchable attributes of the index + ------- + settings: list + List containing the searchable attributes of the index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( self.__settings_url_for(self.config.paths.searchable_attributes) @@ -572,18 +707,23 @@ def get_searchable_attributes(self): def update_searchable_attributes(self, body): """ - Update searchable attributes of an index + Update searchable attributes of the index. Parameters ---------- - body: `list` - List containing the searchable attributes + body: list + List containing the searchable attributes. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( self.__settings_url_for(self.config.paths.searchable_attributes), @@ -591,13 +731,18 @@ def update_searchable_attributes(self, body): ) def reset_searchable_attributes(self): - """Reset searchable attributes of an index to default values + """Reset searchable attributes of the index to default values. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( self.__settings_url_for(self.config.paths.searchable_attributes), @@ -607,12 +752,17 @@ def reset_searchable_attributes(self): def get_displayed_attributes(self): """ - Get displayed attributes of an index + Get displayed attributes of the index. Returns - ---------- - settings: `list` - List containing the displayed attributes of the index + ------- + settings: list + List containing the displayed attributes of the index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( self.__settings_url_for(self.config.paths.displayed_attributes) @@ -620,18 +770,23 @@ def get_displayed_attributes(self): def update_displayed_attributes(self, body): """ - Update displayed attributes of an index + Update displayed attributes of the index. Parameters ---------- - body: `list` - List containing the displayed attributes + body: list + List containing the displayed attributes. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( self.__settings_url_for(self.config.paths.displayed_attributes), @@ -639,13 +794,18 @@ def update_displayed_attributes(self, body): ) def reset_displayed_attributes(self): - """Reset displayed attributes of an index to default values + """Reset displayed attributes of the index to default values. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( self.__settings_url_for(self.config.paths.displayed_attributes), @@ -655,12 +815,17 @@ def reset_displayed_attributes(self): def get_stop_words(self): """ - Get stop words of an index + Get stop words of the index. Returns - ---------- - settings: `list` - List containing the stop words of the index + ------- + settings: list + List containing the stop words of the index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( self.__settings_url_for(self.config.paths.stop_words) @@ -668,18 +833,23 @@ def get_stop_words(self): def update_stop_words(self, body): """ - Update stop words of an index + Update stop words of the index. Parameters ---------- - body: `list` - List containing the stop words + body: list + List containing the stop words. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( self.__settings_url_for(self.config.paths.stop_words), @@ -687,13 +857,18 @@ def update_stop_words(self, body): ) def reset_stop_words(self): - """Reset stop words of an index to default values + """Reset stop words of the index to default values. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( self.__settings_url_for(self.config.paths.stop_words), @@ -703,12 +878,17 @@ def reset_stop_words(self): def get_synonyms(self): """ - Get synonyms of an index + Get synonyms of the index. Returns - ---------- - settings: `dict` - Dictionnary containing the synonyms of the index + ------- + settings: dict + Dictionary containing the synonyms of the index. + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( self.__settings_url_for(self.config.paths.synonyms) @@ -716,18 +896,23 @@ def get_synonyms(self): def update_synonyms(self, body): """ - Update synonyms of an index + Update synonyms of the index. Parameters ---------- - body: `dict` - Dictionnary containing the synonyms + body: dict + Dictionary containing the synonyms. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( self.__settings_url_for(self.config.paths.synonyms), @@ -735,13 +920,18 @@ def update_synonyms(self, body): ) def reset_synonyms(self): - """Reset synonyms of an index to default values + """Reset synonyms of the index to default values. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( self.__settings_url_for(self.config.paths.synonyms), @@ -751,12 +941,17 @@ def reset_synonyms(self): def get_attributes_for_faceting(self): """ - Get attributes for faceting of an index + Get attributes for faceting of the index. Returns - ---------- - settings: `list` + ------- + settings: list List containing the attributes for faceting of the index + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.get( self.__settings_url_for(self.config.paths.attributes_for_faceting) @@ -764,18 +959,23 @@ def get_attributes_for_faceting(self): def update_attributes_for_faceting(self, body): """ - Update attributes for faceting of an index + Update attributes for faceting of the index. Parameters ---------- - body: `list` - List containing the attributes for faceting + body: list + List containing the attributes for faceting. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.post( self.__settings_url_for(self.config.paths.attributes_for_faceting), @@ -783,13 +983,18 @@ def update_attributes_for_faceting(self, body): ) def reset_attributes_for_faceting(self): - """Reset attributes for faceting of an index to default values + """Reset attributes for faceting of the index to default values. Returns - ---------- - update: `dict` - Dictionnary containing an update id to track the action: + ------- + update: dict + Dictionary containing an update id to track the action: https://docs.meilisearch.com/references/updates.html#get-an-update-status + + Raises + ------ + MeiliSearchApiError + In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code """ return self.http.delete( self.__settings_url_for(self.config.paths.attributes_for_faceting), diff --git a/meilisearch/tests/client/test_client.py b/meilisearch/tests/client/test_client.py index 465938cd..a10bee06 100644 --- a/meilisearch/tests/client/test_client.py +++ b/meilisearch/tests/client/test_client.py @@ -5,20 +5,20 @@ from meilisearch.tests import BASE_URL, MASTER_KEY def test_get_client(): - """Tests getting a client instance""" + """Tests getting a client instance.""" client = meilisearch.Client(BASE_URL, MASTER_KEY) assert client.config response = client.health() assert response.status_code >= 200 and response.status_code < 400 def test_get_client_without_master_key(): - """Tests getting a client instance without MASTER KEY""" + """Tests getting a client instance without master key.""" client = meilisearch.Client(BASE_URL) with pytest.raises(Exception): client.get_version() def test_get_client_with_wrong_master_key(): - """Tests getting a client instance with an invalid MASTER KEY""" + """Tests getting a client instance with an invalid master key.""" client = meilisearch.Client(BASE_URL, MASTER_KEY + "123") with pytest.raises(Exception): client.get_version() diff --git a/meilisearch/tests/client/test_client_dumps.py b/meilisearch/tests/client/test_client_dumps.py index f2844d1a..d1c03aec 100644 --- a/meilisearch/tests/client/test_client_dumps.py +++ b/meilisearch/tests/client/test_client_dumps.py @@ -5,7 +5,7 @@ from meilisearch.errors import MeiliSearchApiError def test_dump_creation(client, index_with_documents): - """Tests the creation of a MeiliSearch dump""" + """Tests the creation of a MeiliSearch dump.""" index_with_documents("indexUID-dump-creation") dump = client.create_dump() assert dump['uid'] is not None @@ -13,7 +13,7 @@ def test_dump_creation(client, index_with_documents): wait_for_dump_creation(client, dump['uid']) def test_dump_status_route(client, index_with_documents): - """Tests the route for getting a MeiliSearch dump status""" + """Tests the route for getting a MeiliSearch dump status.""" index_with_documents("indexUID-dump-status") dump = client.create_dump() assert dump['uid'] is not None @@ -24,6 +24,6 @@ def test_dump_status_route(client, index_with_documents): wait_for_dump_creation(client, dump['uid']) def test_dump_status_nonexistent_uid_raises_error(client): - """Tests the route for getting a nonexistent dump status""" + """Tests the route for getting an inexistent dump status.""" with pytest.raises(MeiliSearchApiError): client.get_dump_status('uid_not_exists') diff --git a/meilisearch/tests/client/test_client_health_meilisearch.py b/meilisearch/tests/client/test_client_health_meilisearch.py index 831ac048..ba3a8c96 100644 --- a/meilisearch/tests/client/test_client_health_meilisearch.py +++ b/meilisearch/tests/client/test_client_health_meilisearch.py @@ -1,5 +1,5 @@ def test_health(client): - """Tests checking the health of MeiliSearch instance""" + """Tests checking the health of the MeiliSearch instance.""" response = client.health() assert response.status_code >= 200 and response.status_code < 400 diff --git a/meilisearch/tests/client/test_client_key_meilisearch.py b/meilisearch/tests/client/test_client_key_meilisearch.py index 51676b16..ec067ced 100644 --- a/meilisearch/tests/client/test_client_key_meilisearch.py +++ b/meilisearch/tests/client/test_client_key_meilisearch.py @@ -1,6 +1,6 @@ def test_get_keys(client): - """Tests if public and private keys are generated and retrieved""" + """Tests if public and private keys have been generated and can be retrieved.""" response = client.get_keys() assert isinstance(response, dict) assert 'public' in response diff --git a/meilisearch/tests/client/test_client_stats_meilisearch.py b/meilisearch/tests/client/test_client_stats_meilisearch.py index 6470508a..db11d19b 100644 --- a/meilisearch/tests/client/test_client_stats_meilisearch.py +++ b/meilisearch/tests/client/test_client_stats_meilisearch.py @@ -2,7 +2,7 @@ @pytest.mark.usefixtures("indexes_sample") def test_get_all_stats(client): - """Tests getting all stats after creating two indexes""" + """Tests getting all stats.""" response = client.get_all_stats() assert isinstance(response, object) assert 'databaseSize' in response diff --git a/meilisearch/tests/client/test_client_version_meilisearch.py b/meilisearch/tests/client/test_client_version_meilisearch.py index 18bcea5e..81a7cb9a 100644 --- a/meilisearch/tests/client/test_client_version_meilisearch.py +++ b/meilisearch/tests/client/test_client_version_meilisearch.py @@ -1,6 +1,6 @@ def test_get_version(client): - """Tests getting the version of the MeiliSearch instance""" + """Tests getting the version of the MeiliSearch instance.""" response = client.get_version() assert 'pkgVersion' in response assert 'commitSha' in response diff --git a/meilisearch/tests/conftest.py b/meilisearch/tests/conftest.py index 8523aca6..935074c2 100644 --- a/meilisearch/tests/conftest.py +++ b/meilisearch/tests/conftest.py @@ -12,43 +12,38 @@ def client(): @fixture(autouse=True) def clear_indexes(client): """ - Auto clear the indexes after each tetst function run. - helps with identifying tests that are not independent. + Auto-clears the indexes after each test function run. + Makes all the test functions independent. """ - # Yield back to the test function + # Yields back to the test function. yield - # test function has finished, let's cleanup + # Deletes all the indexes in the MeiliSearch instance. indexes = client.get_indexes() for index in indexes: client.index(index['uid']).delete() - @fixture(scope='function') def indexes_sample(client): indexes = [] for index_args in common.INDEX_FIXTURE: indexes.append(client.create_index(**index_args)) - # yield the indexes to the test so it can use it + # Yields the indexes to the test to make them accessible. yield indexes - @fixture(scope='session') def small_movies(): """ - Run once per session, provide the content of small_movies.json - as a dictionary to the test. + Runs once per session. Provides the content of small_movies.json. """ with open('./datasets/small_movies.json', 'r') as movie_file: yield json.loads(movie_file.read()) - @fixture(scope='function') def empty_index(client): def index_maker(index_name=common.INDEX_UID): return client.create_index(uid=index_name) return index_maker - @fixture(scope='function') def index_with_documents(empty_index, small_movies): def index_maker(index_name=common.INDEX_UID, documents=small_movies): diff --git a/meilisearch/tests/index/test_index.py b/meilisearch/tests/index/test_index.py index 2b0bc153..fc9440ba 100644 --- a/meilisearch/tests/index/test_index.py +++ b/meilisearch/tests/index/test_index.py @@ -5,7 +5,7 @@ from meilisearch.tests import common def test_create_index(client): - """Tests creating an index""" + """Tests creating an index.""" index = client.create_index(uid=common.INDEX_UID) assert isinstance(index, Index) assert index.uid == common.INDEX_UID @@ -13,7 +13,7 @@ def test_create_index(client): assert index.get_primary_key() is None def test_create_index_with_primary_key(client): - """Tests creating an index with a primary key""" + """Tests creating an index with a primary key.""" index = client.create_index(uid=common.INDEX_UID2, options={'primaryKey': 'book_id'}) assert isinstance(index, Index) assert index.uid == common.INDEX_UID2 @@ -21,7 +21,7 @@ def test_create_index_with_primary_key(client): assert index.get_primary_key() == 'book_id' def test_create_index_with_uid_in_options(client): - """Tests creating an index with a primary key""" + """Tests creating an index with a primary key.""" index = client.create_index(uid=common.INDEX_UID3, options={'uid': 'wrong', 'primaryKey': 'book_id'}) assert isinstance(index, Index) assert index.uid == common.INDEX_UID3 @@ -30,7 +30,7 @@ def test_create_index_with_uid_in_options(client): @pytest.mark.usefixtures("indexes_sample") def test_get_indexes(client): - """Tests getting all indexes""" + """Tests getting all indexes.""" response = client.get_indexes() uids = [index['uid'] for index in response] assert isinstance(response, list) @@ -53,23 +53,23 @@ def test_index_with_none_uid(client): @pytest.mark.usefixtures("indexes_sample") def test_get_index_with_valid_uid(client): - """Tests getting one index with uid""" + """Tests getting one index with uid.""" response = client.get_index(uid=common.INDEX_UID) assert isinstance(response, Index) assert response.uid == common.INDEX_UID def test_get_index_with_none_uid(client): - """Test raising an exception if the index UID is None""" + """Test raising an exception if the index UID is None.""" with pytest.raises(Exception): client.get_index(uid=None) def test_get_index_with_wrong_uid(client): - """Tests get_index with an non-existing index""" + """Tests get_index with an non-existing index.""" with pytest.raises(Exception): client.get_index(uid='wrongUID') def test_get_or_create_index(client): - """Test get_or_create_index method""" + """Test get_or_create_index method.""" index_1 = client.get_or_create_index(common.INDEX_UID4) index_2 = client.get_or_create_index(common.INDEX_UID4) index_3 = client.get_or_create_index(common.INDEX_UID4) @@ -86,7 +86,7 @@ def test_get_or_create_index(client): client.get_index(index_3) def test_get_or_create_index_with_primary_key(client): - """Test get_or_create_index method with primary key""" + """Test get_or_create_index method with primary key.""" index_1 = client.get_or_create_index('books', {'primaryKey': common.INDEX_UID4}) index_2 = client.get_or_create_index('books', {'primaryKey': 'some_wrong_key'}) assert index_1.primary_key == common.INDEX_UID4 @@ -97,7 +97,7 @@ def test_get_or_create_index_with_primary_key(client): @pytest.mark.usefixtures("indexes_sample") def test_index_fetch_info(client): - """Tests getting the index info""" + """Tests fetching the index info.""" index = client.index(uid=common.INDEX_UID) response = index.fetch_info() assert isinstance(response, Index) @@ -108,7 +108,7 @@ def test_index_fetch_info(client): @pytest.mark.usefixtures("indexes_sample") def test_index_fetch_info_containing_primary_key(client): - """Tests getting the index info""" + """Tests fetching the index info when a primary key has been set.""" index = client.index(uid=common.INDEX_UID3) response = index.fetch_info() assert isinstance(response, Index) @@ -119,7 +119,7 @@ def test_index_fetch_info_containing_primary_key(client): @pytest.mark.usefixtures("indexes_sample") def test_get_primary_key(client): - """Tests getting the primary-key of an index""" + """Tests getting the primary key of an index.""" index = client.index(uid=common.INDEX_UID3) assert index.primary_key is None response = index.get_primary_key() @@ -129,7 +129,7 @@ def test_get_primary_key(client): @pytest.mark.usefixtures("indexes_sample") def test_update_index(client): - """Tests updating an index""" + """Tests updating an index.""" index = client.index(uid=common.INDEX_UID) response = index.update(primaryKey='objectID') assert isinstance(response, Index) @@ -138,7 +138,7 @@ def test_update_index(client): @pytest.mark.usefixtures("indexes_sample") def test_delete_index(client): - """Tests deleting an index""" + """Tests deleting an index.""" response = client.index(uid=common.INDEX_UID).delete() assert response.status_code == 204 with pytest.raises(Exception): diff --git a/meilisearch/tests/index/test_index_document_meilisearch.py b/meilisearch/tests/index/test_index_document_meilisearch.py index 3e69fa7a..37adf1d2 100644 --- a/meilisearch/tests/index/test_index_document_meilisearch.py +++ b/meilisearch/tests/index/test_index_document_meilisearch.py @@ -3,13 +3,13 @@ import pytest def test_get_documents_default(empty_index): - """Tests getting documents on a clean index""" + """Tests getting documents on a clean index.""" response = empty_index().get_documents() assert isinstance(response, list) assert response == [] def test_add_documents(empty_index, small_movies): - """Tests adding new documents to a clean index""" + """Tests adding new documents to a clean index.""" index = empty_index() response = index.add_documents(small_movies) assert isinstance(response, object) @@ -19,29 +19,26 @@ def test_add_documents(empty_index, small_movies): assert update['status'] == 'processed' def test_get_document(index_with_documents): - """Tests getting one document on a populated index""" + """Tests getting one document from a populated index.""" response = index_with_documents().get_document('500682') assert isinstance(response, object) assert 'title' in response assert response['title'] == 'The Highwaymen' def test_get_document_inexistent(empty_index): - """Tests getting one INEXISTENT document on a populated index""" + """Tests getting one inexistent document from a populated index.""" with pytest.raises(Exception): empty_index().get_document('123') def test_get_documents_populated(index_with_documents): - """Tests getting documents on a populated index""" - + """Tests getting documents from a populated index.""" response = index_with_documents().get_documents() assert isinstance(response, list) assert len(response) == 20 -def test_get_documents_offset_optional_params(index_with_documents, small_movies): - """Tests getting documents on a populated index with optional parameters""" - # Add movies to the index +def test_get_documents_offset_optional_params(index_with_documents): + """Tests getting documents from a populated index with optional parameters.""" index = index_with_documents() - index.add_documents(small_movies) response = index.get_documents() assert isinstance(response, list) assert len(response) == 20 @@ -54,7 +51,7 @@ def test_get_documents_offset_optional_params(index_with_documents, small_movies assert response_offset_limit[0]['title'] == response[1]['title'] def test_update_documents(index_with_documents, small_movies): - """Tests updating a single document and a set of documents """ + """Tests updating a single document and a set of documents.""" index = index_with_documents() response = index.get_documents() response[0]['title'] = 'Some title' @@ -70,7 +67,7 @@ def test_update_documents(index_with_documents, small_movies): assert response[0]['title'] != 'Some title' def test_delete_document(index_with_documents): - """Tests deleting a single document""" + """Tests deleting a single document.""" index = index_with_documents() response = index.delete_document('500682') assert isinstance(response, object) @@ -80,7 +77,7 @@ def test_delete_document(index_with_documents): index.get_document('500682') def test_delete_documents(index_with_documents): - """Tests deleting a set of documents """ + """Tests deleting a set of documents.""" to_delete = ['522681', '450465', '329996'] index = index_with_documents() response = index.delete_documents(to_delete) @@ -92,7 +89,7 @@ def test_delete_documents(index_with_documents): index.get_document(document) def test_delete_all_documents(index_with_documents): - """Tests updating all the documents in the index""" + """Tests deleting all the documents in the index.""" index = index_with_documents() response = index.delete_all_documents() assert isinstance(response, object) diff --git a/meilisearch/tests/index/test_index_search_meilisearch.py b/meilisearch/tests/index/test_index_search_meilisearch.py index 6e1789c5..d9be0ea5 100644 --- a/meilisearch/tests/index/test_index_search_meilisearch.py +++ b/meilisearch/tests/index/test_index_search_meilisearch.py @@ -1,33 +1,33 @@ # pylint: disable=invalid-name def test_basic_search(index_with_documents): - """Tests search with an simple query""" + """Tests search with an simple query.""" response = index_with_documents().search('How to Train Your Dragon') assert isinstance(response, object) assert response['hits'][0]['id'] == '166428' def test_basic_search_with_empty_params(index_with_documents): - """Tests search with an simple query and empty params""" + """Tests search with a simple query and empty params.""" response = index_with_documents().search('How to Train Your Dragon', {}) assert isinstance(response, object) assert response['hits'][0]['id'] == '166428' assert '_formatted' not in response['hits'][0] def test_basic_search_with_empty_query(index_with_documents): - """Tests search with empty query and empty params""" + """Tests search with an empty query and empty params.""" response = index_with_documents().search('') assert isinstance(response, object) assert len(response['hits']) == 20 assert response['query'] == '' -def test_basic_search_with_placeholder(index_with_documents): - """Tests search with no query [None] and empty params""" +def test_basic_search_with_no_query(index_with_documents): + """Tests search with no query [None] and empty params.""" response = index_with_documents().search(None, {}) assert isinstance(response, object) assert len(response['hits']) == 20 def test_custom_search(index_with_documents): - """Tests search with an simple query and custom parameter (attributesToHighlight)""" + """Tests search with a simple query and a custom parameter (attributesToHighlight).""" response = index_with_documents().search( 'Dragon', { @@ -40,7 +40,7 @@ def test_custom_search(index_with_documents): assert 'dragon' in response['hits'][0]['_formatted']['title'].lower() def test_custom_search_with_empty_query(index_with_documents): - """Tests search with empty query and custom parameter (attributesToHighlight)""" + """Tests search with an empty query and custom parameter (attributesToHighlight).""" response = index_with_documents().search( '', { @@ -51,8 +51,8 @@ def test_custom_search_with_empty_query(index_with_documents): assert len(response['hits']) == 20 assert response['query'] == '' -def test_custom_search_with_placeholder(index_with_documents): - """Tests search with no query [None] and custom parameter (limit)""" +def test_custom_search_with_no_query(index_with_documents): + """Tests search with no query [None] and a custom parameter (limit).""" response = index_with_documents().search( None, { @@ -63,7 +63,7 @@ def test_custom_search_with_placeholder(index_with_documents): assert len(response['hits']) == 5 def test_custom_search_params_with_wildcard(index_with_documents): - """Tests search with '*' in query params""" + """Tests search with '*' in query params.""" response = index_with_documents().search( 'a', { @@ -79,7 +79,7 @@ def test_custom_search_params_with_wildcard(index_with_documents): assert "title" in response['hits'][0]['_formatted'] def test_custom_search_params_with_simple_string(index_with_documents): - """Tests search with simple string in query params""" + """Tests search with a list of one string in query params.""" response = index_with_documents().search( 'a', { @@ -96,7 +96,7 @@ def test_custom_search_params_with_simple_string(index_with_documents): assert not 'release_date' in response['hits'][0]['_formatted'] def test_custom_search_params_with_string_list(index_with_documents): - """Tests search with string list in query params""" + """Tests search with string list in query params.""" response = index_with_documents().search( 'a', { diff --git a/meilisearch/tests/index/test_index_stats_meilisearch.py b/meilisearch/tests/index/test_index_stats_meilisearch.py index bb824ca8..80e8848a 100644 --- a/meilisearch/tests/index/test_index_stats_meilisearch.py +++ b/meilisearch/tests/index/test_index_stats_meilisearch.py @@ -1,7 +1,7 @@ def test_get_stats(empty_index): - """Tests getting stats of a single index""" + """Tests getting stats of an index.""" response = empty_index().get_stats() assert isinstance(response, object) assert 'numberOfDocuments' in response diff --git a/meilisearch/tests/index/test_index_update_meilisearch.py b/meilisearch/tests/index/test_index_update_meilisearch.py index 88a99282..d52887a1 100644 --- a/meilisearch/tests/index/test_index_update_meilisearch.py +++ b/meilisearch/tests/index/test_index_update_meilisearch.py @@ -3,13 +3,13 @@ import pytest def test_get_all_update_status_default(empty_index): - """Tests getting the updates list of an empty index""" + """Tests getting the updates list of an empty index.""" response = empty_index().get_all_update_status() assert isinstance(response, list) assert response == [] def test_get_all_update_status(empty_index, small_movies): - """Tests getting the updates list of a populated index""" + """Tests getting the updates list of a populated index.""" index = empty_index() response = index.add_documents(small_movies) assert 'updateId' in response @@ -19,7 +19,7 @@ def test_get_all_update_status(empty_index, small_movies): assert len(response) == 2 def test_get_update(empty_index, small_movies): - """Tests getting an update of a given operation""" + """Tests getting an update of a given operation.""" index = empty_index() response = index.add_documents(small_movies) assert 'updateId' in response @@ -33,6 +33,6 @@ def test_get_update(empty_index, small_movies): assert 'processedAt' in response def test_get_update_inexistent(empty_index): - """Tests getting an update of an INEXISTENT operation""" + """Tests getting an update of an inexistent operation.""" with pytest.raises(Exception): empty_index().get_update_status('999') diff --git a/meilisearch/tests/index/test_index_wait_for_pending_update.py b/meilisearch/tests/index/test_index_wait_for_pending_update.py index 37ec495e..55ed7f1b 100644 --- a/meilisearch/tests/index/test_index_wait_for_pending_update.py +++ b/meilisearch/tests/index/test_index_wait_for_pending_update.py @@ -4,7 +4,7 @@ import pytest def test_wait_for_pending_update_default(index_with_documents): - """Tests waiting for an update with default parameters""" + """Tests waiting for an update with default parameters.""" index = index_with_documents() response = index.add_documents([{'id': 1, 'title': 'Le Petit Prince'}]) assert 'updateId' in response @@ -14,12 +14,12 @@ def test_wait_for_pending_update_default(index_with_documents): assert update['status'] != 'enqueued' def test_wait_for_pending_update_timeout(index_with_documents): - """Tests timeout risen by waiting for an update""" + """Tests timeout risen by waiting for an update.""" with pytest.raises(TimeoutError): index_with_documents().wait_for_pending_update(2, timeout_in_ms=0) def test_wait_for_pending_update_interval_custom(index_with_documents, small_movies): - """Tests call to wait for an update with custom interval""" + """Tests call to wait for an update with custom interval.""" index = index_with_documents() response = index.add_documents(small_movies) assert 'updateId' in response @@ -36,7 +36,7 @@ def test_wait_for_pending_update_interval_custom(index_with_documents, small_mov assert time_delta.seconds >= 1 def test_wait_for_pending_update_interval_zero(index_with_documents, small_movies): - """Tests call to wait for an update with custom interval""" + """Tests call to wait for an update with custom interval.""" index = index_with_documents() response = index.add_documents(small_movies) assert 'updateId' in response diff --git a/meilisearch/tests/settings/test_settings.py b/meilisearch/tests/settings/test_settings.py index eb8acfbc..a54d1ae0 100644 --- a/meilisearch/tests/settings/test_settings.py +++ b/meilisearch/tests/settings/test_settings.py @@ -14,7 +14,7 @@ ] def test_get_settings_default(empty_index): - """Tests getting all settings by default""" + """Tests getting all settings by default.""" response = empty_index().get_settings() assert isinstance(response, object) for rule in DEFAULT_RANKING_RULES: @@ -26,7 +26,7 @@ def test_get_settings_default(empty_index): assert response['synonyms'] == {} def test_update_settings(empty_index): - """Tests updating some settings""" + """Tests updating some settings.""" index = empty_index() response = index.update_settings(NEW_SETTINGS) assert isinstance(response, object) @@ -44,7 +44,7 @@ def test_update_settings(empty_index): assert response['synonyms'] == {} def test_reset_settings(empty_index): - """Tests resetting default settings""" + """Tests resetting all the settings to their default value.""" index = empty_index() # Update settings first response = index.update_settings(NEW_SETTINGS) diff --git a/meilisearch/tests/settings/test_settings_attributes_for_faceting_meilisearch.py b/meilisearch/tests/settings/test_settings_attributes_for_faceting_meilisearch.py index 29d3d0c5..989ef23e 100644 --- a/meilisearch/tests/settings/test_settings_attributes_for_faceting_meilisearch.py +++ b/meilisearch/tests/settings/test_settings_attributes_for_faceting_meilisearch.py @@ -3,13 +3,13 @@ ATTRIBUTES_FOR_FACETING = ['title', 'release_date'] def test_get_attributes_for_faceting(empty_index): - """ Tests getting the attributes for faceting """ + """Tests getting the attributes for faceting.""" response = empty_index().get_attributes_for_faceting() assert isinstance(response, object) assert response == [] def test_update_attributes_for_faceting(empty_index): - """Tests updating the attributes for faceting""" + """Tests updating the attributes for faceting.""" index = empty_index() response = index.update_attributes_for_faceting(ATTRIBUTES_FOR_FACETING) index.wait_for_pending_update(response['updateId']) @@ -20,7 +20,7 @@ def test_update_attributes_for_faceting(empty_index): assert attribute in get_attributes def test_reset_attributes_for_faceting(empty_index): - """Tests the reset of attributes for faceting to default values (in dataset)""" + """Tests resetting the attributes for faceting setting to its default value""" index = empty_index() # Update the settings first response = index.update_attributes_for_faceting(ATTRIBUTES_FOR_FACETING) diff --git a/meilisearch/tests/settings/test_settings_displayed_attributes_meilisearch.py b/meilisearch/tests/settings/test_settings_displayed_attributes_meilisearch.py index b5b8e3ba..e7ccab75 100644 --- a/meilisearch/tests/settings/test_settings_displayed_attributes_meilisearch.py +++ b/meilisearch/tests/settings/test_settings_displayed_attributes_meilisearch.py @@ -4,7 +4,7 @@ def test_get_displayed_attributes(empty_index, small_movies): - """ Tests getting the displayed attributes before and after indexing a dataset """ + """Tests getting the displayed attributes before and after indexing a dataset.""" index = empty_index() response = index.get_displayed_attributes() assert isinstance(response, object) @@ -15,7 +15,7 @@ def test_get_displayed_attributes(empty_index, small_movies): assert get_attributes == ['*'] def test_update_displayed_attributes(empty_index): - """Tests updating the displayed attributes""" + """Tests updating the displayed attributes.""" index = empty_index() response = index.update_displayed_attributes(DISPLAYED_ATTRIBUTES) index.wait_for_pending_update(response['updateId']) @@ -25,7 +25,7 @@ def test_update_displayed_attributes(empty_index): assert attribute in get_attributes_new def test_reset_displayed_attributes(empty_index): - """Tests the reset of displayedAttributes to default values (in dataset)""" + """Tests resetting the displayed attributes setting to its default value.""" index = empty_index() # Update the settings first response = index.update_displayed_attributes(DISPLAYED_ATTRIBUTES) diff --git a/meilisearch/tests/settings/test_settings_distinct_attribute_meilisearch.py b/meilisearch/tests/settings/test_settings_distinct_attribute_meilisearch.py index c0de394b..6557b1dd 100644 --- a/meilisearch/tests/settings/test_settings_distinct_attribute_meilisearch.py +++ b/meilisearch/tests/settings/test_settings_distinct_attribute_meilisearch.py @@ -4,13 +4,13 @@ DEFAULT_DISTINCT_ATTRIBUTE = None def test_get_distinct_attribute(empty_index): - """Tests geting the distinct attributes""" + """Tests geting the distinct attribute.""" response = empty_index().get_distinct_attribute() assert isinstance(response, object) assert response == DEFAULT_DISTINCT_ATTRIBUTE def test_update_distinct_attribute(empty_index): - """Tests creating a custom distinct attribute and checks it has been set correctly""" + """Tests updating a custom distinct attribute.""" index = empty_index() response = index.update_distinct_attribute(NEW_DISTINCT_ATTRIBUTE) assert isinstance(response, object) @@ -21,7 +21,7 @@ def test_update_distinct_attribute(empty_index): assert response == NEW_DISTINCT_ATTRIBUTE def test_reset_distinct_attribute(empty_index): - """Tests resetting distinct attribute""" + """Tests resetting the distinct attribute setting to its default value.""" index = empty_index() # Update the settings first response = index.update_distinct_attribute(NEW_DISTINCT_ATTRIBUTE) diff --git a/meilisearch/tests/settings/test_settings_ranking_rules_meilisearch.py b/meilisearch/tests/settings/test_settings_ranking_rules_meilisearch.py index 8bed3e61..6d231362 100644 --- a/meilisearch/tests/settings/test_settings_ranking_rules_meilisearch.py +++ b/meilisearch/tests/settings/test_settings_ranking_rules_meilisearch.py @@ -10,14 +10,14 @@ ] def test_get_ranking_rules_default(empty_index): - """Tests getting the default ranking rules""" + """Tests getting the default ranking rules.""" response = empty_index().get_ranking_rules() assert isinstance(response, object) for rule in DEFAULT_RANKING_RULES: assert rule in response def test_update_ranking_rules(empty_index): - """Tests changing the ranking rules""" + """Tests changing the ranking rules.""" index = empty_index() response = index.update_ranking_rules(NEW_RANKING_RULES) assert isinstance(response, object) @@ -29,7 +29,7 @@ def test_update_ranking_rules(empty_index): assert rule in response def test_reset_ranking_rules(empty_index): - """Tests resetting the ranking rules""" + """Tests resetting the ranking rules setting to its default value.""" index = empty_index() # Update the settings first response = index.update_ranking_rules(NEW_RANKING_RULES) diff --git a/meilisearch/tests/settings/test_settings_searchable_attributes_meilisearch.py b/meilisearch/tests/settings/test_settings_searchable_attributes_meilisearch.py index a6c37643..40afde2c 100644 --- a/meilisearch/tests/settings/test_settings_searchable_attributes_meilisearch.py +++ b/meilisearch/tests/settings/test_settings_searchable_attributes_meilisearch.py @@ -3,7 +3,7 @@ NEW_SEARCHABLE_ATTRIBUTES = ['something', 'random'] def test_get_searchable_attributes(empty_index, small_movies): - """Tests getting the searchable attributes on an empty and populated index""" + """Tests getting the searchable attributes on an empty and populated index.""" index = empty_index() response = index.get_searchable_attributes() assert isinstance(response, object) @@ -15,7 +15,7 @@ def test_get_searchable_attributes(empty_index, small_movies): def test_update_searchable_attributes(empty_index): - """Tests updating the searchable attributes""" + """Tests updating the searchable attributes.""" index = empty_index() response = index.update_searchable_attributes(NEW_SEARCHABLE_ATTRIBUTES) assert isinstance(response, object) @@ -27,7 +27,7 @@ def test_update_searchable_attributes(empty_index): assert attribute in response def test_reset_searchable_attributes(empty_index): - """Tests reseting searchable attributes""" + """Tests resetting the searchable attributes setting to its default value.""" index = empty_index() # Update the settings first response = index.update_searchable_attributes(NEW_SEARCHABLE_ATTRIBUTES) diff --git a/meilisearch/tests/settings/test_settings_stop_words_meilisearch.py b/meilisearch/tests/settings/test_settings_stop_words_meilisearch.py index d5073693..c8abbe25 100644 --- a/meilisearch/tests/settings/test_settings_stop_words_meilisearch.py +++ b/meilisearch/tests/settings/test_settings_stop_words_meilisearch.py @@ -2,13 +2,13 @@ NEW_STOP_WORDS = ['of', 'the'] def test_get_stop_words_default(empty_index): - """Tests call to get stop words by default""" + """Tests getting stop words by default.""" response = empty_index().get_stop_words() assert isinstance(response, object) assert response == [] def test_update_stop_words(empty_index): - """Tests call to modify stop words""" + """Tests updating the stop words.""" index = empty_index() response = index.update_stop_words(NEW_STOP_WORDS) assert isinstance(response, object) @@ -21,7 +21,7 @@ def test_update_stop_words(empty_index): assert stop_word in response def test_reset_stop_words(empty_index): - """Tests call to reset stop words""" + """Tests resetting the stop words setting to its default value""" index = empty_index() # Update the settings first response = index.update_stop_words(NEW_STOP_WORDS) diff --git a/meilisearch/tests/settings/test_settings_synonyms_meilisearch.py b/meilisearch/tests/settings/test_settings_synonyms_meilisearch.py index e45bdb92..ae8b05b3 100644 --- a/meilisearch/tests/settings/test_settings_synonyms_meilisearch.py +++ b/meilisearch/tests/settings/test_settings_synonyms_meilisearch.py @@ -4,13 +4,13 @@ } def test_get_synonyms_default(empty_index): - """Tests getting default synonyms""" + """Tests getting default synonyms.""" response = empty_index().get_synonyms() assert isinstance(response, object) assert response == {} def test_update_synonyms(empty_index): - """Tests updating synonyms""" + """Tests updating synonyms.""" index = empty_index() response = index.update_synonyms(NEW_SYNONYMS) assert isinstance(response, object) @@ -23,7 +23,7 @@ def test_update_synonyms(empty_index): assert synonym in response def test_reset_synonyms(empty_index): - """Tests resetting synonyms""" + """Tests resetting the synonyms setting to its default value.""" index = empty_index() # Update the settings first response = index.update_synonyms(NEW_SYNONYMS) From 1e7fba8ace59a92173a09f92f3e3aa8125de0ef7 Mon Sep 17 00:00:00 2001 From: Clementine Urquizar Date: Mon, 7 Dec 2020 19:03:16 +0100 Subject: [PATCH 2/2] Update error comments --- meilisearch/client.py | 22 ++++++------ meilisearch/index.py | 82 +++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/meilisearch/client.py b/meilisearch/client.py index d97e2384..8343ed76 100644 --- a/meilisearch/client.py +++ b/meilisearch/client.py @@ -44,7 +44,7 @@ def create_index(self, uid, options=None): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return Index.create(self.config, uid, options) @@ -59,7 +59,7 @@ def get_indexes(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get(self.config.paths.index) @@ -80,7 +80,7 @@ def get_index(self, uid): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return Index(self.config, uid).fetch_info() @@ -120,7 +120,7 @@ def get_or_create_index(self, uid, options=None): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ try: index_instance = self.get_index(uid) @@ -144,7 +144,7 @@ def get_all_stats(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get(self.config.paths.stat) @@ -156,7 +156,7 @@ def health(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get(self.config.paths.health) @@ -174,7 +174,7 @@ def get_keys(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get(self.config.paths.keys) @@ -189,7 +189,7 @@ def get_version(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get(self.config.paths.version) @@ -204,7 +204,7 @@ def version(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.get_version() @@ -220,7 +220,7 @@ def create_dump(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post(self.config.paths.dumps) @@ -241,7 +241,7 @@ def get_dump_status(self, uid): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( self.config.paths.dumps + '/' + str(uid) + '/status' diff --git a/meilisearch/index.py b/meilisearch/index.py index 1346c346..c25a788e 100644 --- a/meilisearch/index.py +++ b/meilisearch/index.py @@ -39,7 +39,7 @@ def delete(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete('{}/{}'.format(self.config.paths.index, self.uid)) @@ -60,7 +60,7 @@ def update(self, **body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ payload = {} primary_key = body.get('primaryKey', None) @@ -81,7 +81,7 @@ def fetch_info(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ index_dict = self.http.get('{}/{}'.format(self.config.paths.index, self.uid)) self.primary_key = index_dict['primaryKey'] @@ -98,7 +98,7 @@ def get_primary_key(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.fetch_info().primary_key @@ -121,7 +121,7 @@ def create(cls, config, uid, options=None): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ if options is None: options = {} @@ -140,7 +140,7 @@ def get_all_update_status(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( '{}/{}/{}'.format( @@ -166,7 +166,7 @@ def get_update_status(self, update_id): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( '{}/{}/{}/{}'.format( @@ -197,7 +197,7 @@ def wait_for_pending_update(self, update_id, timeout_in_ms=5000, interval_in_ms= Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ start_time = datetime.now() elapsed_time = 0 @@ -224,7 +224,7 @@ def get_stats(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( '{}/{}/{}'.format( @@ -253,7 +253,7 @@ def search(self, query, opt_params=None): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ if opt_params is None: opt_params = {} @@ -285,7 +285,7 @@ def get_document(self, document_id): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( '{}/{}/{}/{}'.format( @@ -312,7 +312,7 @@ def get_documents(self, parameters=None): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ if parameters is None: parameters = {} @@ -344,7 +344,7 @@ def add_documents(self, documents, primary_key=None): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ if primary_key is None: url = '{}/{}/{}'.format( @@ -380,7 +380,7 @@ def update_documents(self, documents, primary_key=None): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ if primary_key is None: url = '{}/{}/{}'.format( @@ -415,7 +415,7 @@ def delete_document(self, document_id): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( '{}/{}/{}/{}'.format( @@ -443,7 +443,7 @@ def delete_documents(self, ids): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( '{}/{}/{}/delete-batch'.format( @@ -466,7 +466,7 @@ def delete_all_documents(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( '{}/{}/{}'.format( @@ -492,7 +492,7 @@ def get_settings(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( '{}/{}/{}'.format( @@ -523,7 +523,7 @@ def update_settings(self, body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( '{}/{}/{}'.format( @@ -548,7 +548,7 @@ def reset_settings(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( '{}/{}/{}'.format( @@ -572,7 +572,7 @@ def get_ranking_rules(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( self.__settings_url_for(self.config.paths.ranking_rules) @@ -596,7 +596,7 @@ def update_ranking_rules(self, body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( self.__settings_url_for(self.config.paths.ranking_rules), @@ -615,7 +615,7 @@ def reset_ranking_rules(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( self.__settings_url_for(self.config.paths.ranking_rules), @@ -636,7 +636,7 @@ def get_distinct_attribute(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( self.__settings_url_for(self.config.paths.distinct_attribute) @@ -660,7 +660,7 @@ def update_distinct_attribute(self, body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( self.__settings_url_for(self.config.paths.distinct_attribute), @@ -679,7 +679,7 @@ def reset_distinct_attribute(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( self.__settings_url_for(self.config.paths.distinct_attribute), @@ -699,7 +699,7 @@ def get_searchable_attributes(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( self.__settings_url_for(self.config.paths.searchable_attributes) @@ -723,7 +723,7 @@ def update_searchable_attributes(self, body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( self.__settings_url_for(self.config.paths.searchable_attributes), @@ -742,7 +742,7 @@ def reset_searchable_attributes(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( self.__settings_url_for(self.config.paths.searchable_attributes), @@ -762,7 +762,7 @@ def get_displayed_attributes(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( self.__settings_url_for(self.config.paths.displayed_attributes) @@ -786,7 +786,7 @@ def update_displayed_attributes(self, body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( self.__settings_url_for(self.config.paths.displayed_attributes), @@ -805,7 +805,7 @@ def reset_displayed_attributes(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( self.__settings_url_for(self.config.paths.displayed_attributes), @@ -825,7 +825,7 @@ def get_stop_words(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( self.__settings_url_for(self.config.paths.stop_words) @@ -849,7 +849,7 @@ def update_stop_words(self, body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( self.__settings_url_for(self.config.paths.stop_words), @@ -868,7 +868,7 @@ def reset_stop_words(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( self.__settings_url_for(self.config.paths.stop_words), @@ -888,7 +888,7 @@ def get_synonyms(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( self.__settings_url_for(self.config.paths.synonyms) @@ -912,7 +912,7 @@ def update_synonyms(self, body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( self.__settings_url_for(self.config.paths.synonyms), @@ -931,7 +931,7 @@ def reset_synonyms(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( self.__settings_url_for(self.config.paths.synonyms), @@ -951,7 +951,7 @@ def get_attributes_for_faceting(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.get( self.__settings_url_for(self.config.paths.attributes_for_faceting) @@ -975,7 +975,7 @@ def update_attributes_for_faceting(self, body): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.post( self.__settings_url_for(self.config.paths.attributes_for_faceting), @@ -994,7 +994,7 @@ def reset_attributes_for_faceting(self): Raises ------ MeiliSearchApiError - In case of any HTTP code error described here https://docs.meilisearch.com/references/#errors-status-code + An error containing details about why MeiliSearch can't process your request. MeiliSearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors """ return self.http.delete( self.__settings_url_for(self.config.paths.attributes_for_faceting),