Exemplo n.º 1
0
    def create_index(self, uid, options=None):
        """Create an index.

        If the argument `uid` isn't passed in, it will be generated
        by MeiliSearch.

        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 other error found here https://docs.meilisearch.com/references/#errors-status-code
        """
        index = Index(self.config, uid)
        index.create(self.config, uid, options)
        return index
Exemplo n.º 2
0
    def create_index(self, name, uid=None, schema=None):
        """Create an index.

        If the argument `uid` isn't passed in, it will be generated
        by meilisearch.

        Parameters
        ----------
        name: str
            Name of the index
        uid: str, optional
            uid of the index
        schema: dict, optional
            dict containing the schema of the index.
            https://docs.meilisearch.com/main_concepts/indexes.html#schema-definition
        Returns
        -------
        index : 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
        """
        index = Index.create(self.config, name=name, uid=uid, schema=schema)
        return Index(self.config,
                     name=index["name"],
                     uid=index["uid"],
                     schema=schema)
Exemplo n.º 3
0
    def create_index(self, uid, primary_key=None, name=None):
        """Create an index.

        If the argument `uid` isn't passed in, it will be generated
        by MeiliSearch.

        Parameters
        ----------
        uid: str
            UID of the index
        primary_key: str, optional
            Attribute used as unique document identifier
        name: str, optional
            Name of the index
        Returns
        -------
        index : 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
        """
        index = Index.create(self.config,
                             uid=uid,
                             primary_key=primary_key,
                             name=name)
        return Index(self.config, uid=index['uid'])
Exemplo n.º 4
0
    def create_index(self, uid, options=None):
        """Create an index.

        Parameters
        ----------
        uid: str
            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.

        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
        """
        return Index.create(self.config, uid, options)