One way of interacting with the Weaviate cluster is using the Weaviate CLI tool. This command-line tool provides a simple interface to interact and perform the administrative tasks, manage the data, and cluster configuration.
In this tutorial, we will walk you through installing and using the Weaviate CLI on your machine.
Requirements:
To follow along with this tutorial, ensure that you have the following:
- A running Weaviate cluster
- Python 3.10 and above
Installing the Weaviate CLI
The first step is to install the Weaviate CLI on your machine. Luckily, the Weaviate CLI is available as a Python package which means that we can install it using pip as shown in the following command:
Once installed, you may need to perform the basic configuration. You can do this by running the following command:
This should prompt you to provide the details to your Weaviate cluster such as the authentication methods and API keys.
Once configured, verify that everything is working correctly by running the following command:
The command should return the installed Weaviate version.
Weaviate View Configuration
One of the major use of the Weaviate CLI is performing the configuration. The first command allows you to view the configuration for your Weaviate CLI.
Use the command as follows:
You should get the configuration details including the authentication details. An example output is as follows:
"url": "https://linuxhint-yls99k5n.weaviate.network",
"auth": null
}
Weaviate Ping
The second command lets you ping the Weaviate server that is configured in the Weaviate CLI. You can use the “ping” command to ensure that the server is running:
The command should print a status message that shows whether the server is reachable.
Weaviate is reachable!
Weaviate CLI Version
To check the installed version of the Weaviate CLI, you can use the following command:
Output:
Weaviate Schema Import, Export, and Delete
Another set of commands from the Weaviate CLI allows you to import, export, or delete a Weaviate schema.
Add a schema Weaviate CLI:
Export an existing Weaviate schema with the following command:
To delete a schema and all the data associated with it, you can use the “delete” command:
Weaviate CLI Data Import and Delete
We also import or delete the data using the Weaviate CLI as follows. To import the data from a JSON file, use the following command:
To delete all the data objects in Weaviate, we can use the following command:
This should wipe all the data in the cluster.
Conclusion
We covered the basics of installing, configuring, and using the various commands provided by the Weaviate CLI. Keep in mind that depending on the version that you are using, there may be more or less functionality than what is discussed in this post.