AI

Weaviate CLI

Weaviate is a free and open-source, cloud-native, and decentralized knowledge graph system that is designed to store and retrieve the complex data in a highly scalable and efficient manner. Weaviate is built to handle the vectorized data which allows it to perform the advanced semantic searches and other machine-learning tasks.

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:

  1. A running Weaviate cluster
  2. 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:

$ pip3 install weaviate-cli

Once installed, you may need to perform the basic configuration. You can do this by running the following command:

$ weaviate init

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:

$ weaviate version

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:

$ weaviate config view

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:

$ weaviate ping

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:

$ weaviate version

Output:

2.2.0

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:

$ weaviate schema import my_schema.json

Export an existing Weaviate schema with the following command:

$ weaviate schema export my_schema.json

To delete a schema and all the data associated with it, you can use the “delete” command:

$ weaviate schema delete

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:

$ weaviate data import my_data_objects.json

To delete all the data objects in Weaviate, we can use the following command:

$ weaviate data delete

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.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list