Beispiel #1
0
    def create(cls, config, uid, options=None):
        """Create the index.

        Parameters
        ----------
        uid: str
            UID of the index.
        options: dict, optional
            Options passed during index creation (ex: { 'primaryKey': 'name' }).

        Returns
        -------
        index : Index
            An instance of Index containing the information of the newly created index.

        Raises
        ------
        MeiliSearchApiError
            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 = {}
        payload = {**options, 'uid': uid}
        index_dict = HttpRequests(config).post(config.paths.index, payload)
        return cls(config, index_dict['uid'], index_dict['primaryKey'])
Beispiel #2
0
    def create(cls, config, uid, options=None):
        """Create the index.

        Parameters
        ----------
        uid: str
            UID of the index.
        options: dict, optional
            Options passed during index creation.
            Ex: Index.create('indexUID', { 'primaryKey': 'name' })

        Returns
        -------
        index : Index
            An Index instance 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
        """
        if options is None:
            options = {}
        payload = {**options, 'uid': uid}
        index_dict = HttpRequests(config).post(config.paths.index, payload)
        return cls(config, index_dict['uid'], index_dict['primaryKey'])
Beispiel #3
0
 def __init__(self, url, apiKey=None):
     """
     Parameters
     ----------
     url : str
         The url to the MeiliSearch API (ex: http://localhost:7700)
     apiKey : str
         The optional API key for MeiliSearch
     """
     self.config = Config(url, apiKey)
     self.http = HttpRequests(self.config)
Beispiel #4
0
    def get_indexes(config):
        """Get all indexes from meilisearch.

        Returns
        -------
        indexes : list
            List of indexes (dict)
        Raises
        ------
        HTTPError
            In case of any error found here https://docs.meilisearch.com/references/#errors-status-code
        """
        return HttpRequests(config).get(config.paths.index)
Beispiel #5
0
 def __init__(self, config, uid):
     """
     Parameters
     ----------
     config : Config
         Config object containing permission and location of meilisearch
     uid: str
         Uid of the index on which to perform the index actions.
     index_path: str
         Index url path
     """
     self.config = config
     self.uid = uid
     self.http = HttpRequests(config)
Beispiel #6
0
 def __init__(self, config, uid, primary_key=None):
     """
     Parameters
     ----------
     config : dict
         Config object containing permission and location of MeiliSearch.
     uid: str
         UID of the index on which to perform the index actions.
     primary_key (optional): str
         Primary-key of the index.
     """
     self.config = config
     self.http = HttpRequests(config)
     self.uid = uid
     self.primary_key = primary_key
Beispiel #7
0
 def __init__(self, config, uid, primary_key=None):
     """
     Parameters
     ----------
     config : dict
         Config object containing MeiliSearch configuration data, such as url and API Key.
     uid: str
         UID of the index in which further actions will be performed.
     primary_key: str, optional
         Primary-key of the index.
     """
     self.config = config
     self.http = HttpRequests(config)
     self.uid = uid
     self.primary_key = primary_key
Beispiel #8
0
    def create(config, uid, options=None):
        """Create an index.

        Parameters
        ----------
        uid: str
            UID of the index
        options: dict, optional
            Options passed during index creation (ex: primaryKey)

        Returns
        -------
        index : 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
        """
        if options is None:
            options = {}
        payload = {**options, 'uid': uid}
        return HttpRequests(config).post(config.paths.index, payload)