Skip to main content

Weaviate CLI

LICENSEย Weaviate on Stackoverflow badgeย Weaviate issues on GitHub badgeย Weaviate version badgeย Weaviate total Docker pulls badgeย Go Report Card

Weaviate CLI version

The current Weaviate CLI version is v2.0.0.

Installationโ€‹

The Weaviate CLI is available on Pypi.org. The package can be easily installed using pip. The client is developed and tested for Python 3.7 and higher.

The Weaviate CLI can be installed with:

$ pip install weaviate-cli

To check if the cli is installed correctly, run:

$ weaviate version

which should return 2.0.0.

Functionsโ€‹

Configurationโ€‹

You need to configure the CLI tool before you can interact with you Weaviate instance. This can be done manually or by adding flags to commands.

  • Manually (interactive):

    $ weaviate config set

    or

    $ weaviate init

    After which you will be asked to enter the Weaviate URL and authentication mode.

  • Flags: if you didn't configure the CLI manually, you can add a configuration flag pointing to a configuration json file (--config-file myconfig.json) with every command you execute.

    $ weaviate --config-file myconfig.json

    in which myconfig.json should look like:

    {
    "url": "http://localhost:8080",
    "auth": null
    }

    or

    {
    "url": "http://localhost:8080",
    "auth": {
    "secret": <your_client_secret>
    }
    }

    or

    {
    "url": "http://localhost:8080",
    "auth": {
    "user": <user name>,
    "pass": <user password>
    }
    }

You can view the configuration with the command:

$ weaviate config view

Pingโ€‹

You can ping the Weaviate URL you're connected to with:

$ weaviate ping

Which returns Weaviate is reachable! if the connection with the Weaviate server is set up correctly.

Schemaโ€‹

There are three operations available with regard to the schema: import, export and truncate.

Importโ€‹

Adding a schema can be done via:

$ weaviate schema import my_schema.json

Where my_schema.json contains the schema as described here.

To overwrite your schema you can use the --force flag, this will clear the index and replace your schema:

$ weaviate schema import --force my_schema.json # using --force will delete your data

Exportโ€‹

You can export a schema to a json file that is present in the Weaviate instance by:

$ weaviate schema export my_schema.json

Where my_schema.json can be replaces by a json file and local location. Naturally this function only outputs the schema to the given location when a schema is present in Weaviate.

Truncateโ€‹

With delete you can remove the entire schema and all the data that is associated with it. You will be asked for confirmation unless the --force flag is added.

$ weaviate schema delete

Dataโ€‹

Importโ€‹

The import function enables data import from a json file. When the flag --fail-on-error is added, this command execution will fail if an error was thrown by Weaviate when loading the data object in.

$ weaviate data import my_data_objects.json

The json file and location is passed in the command. The file needs to be formatted according to the Weaviate data schema, for example:

{
"classes": [
{
"class": "Publication",
"id": "f81bfe5e-16ba-4615-a516-46c2ae2e5a80",
"properties": {
"name": "New York Times"
}
},
{
"class": "Author",
"id": "36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
"properties": {
"name": "Jodi Kantor",
"writesFor": [{
"beacon": "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80",
"href": "/v1/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
}]
}
}
]
}

Emptyโ€‹

With delete you can remove all data objects in Weaviate. You will be asked for confirmation unless the --force flag is added.

$ weaviate data delete

Change logsโ€‹

Check the change logs on GitHub for updates on the latest CLI changes.

More Resourcesโ€‹

If you can't find the answer to your question here, please look at the:

  1. Frequently Asked Questions. Or,
  2. Knowledge base of old issues. Or,
  3. For questions: Stackoverflow. Or,
  4. For issues: GitHub. Or,
  5. Ask your question in the Slack channel.