AI

Weaviate Nodes

Weaviate is a graph-based, cloud-native, vector search engine that leverages the semantic embeddings and knowledge graphs to enable the efficient and accurate search, retrieval, and exploration of complex data structures at scale.

A Weaviate node refers to an individual instance or installation of the Weaviate database. It represents a single unit within a distributed network that stores and processes the data using the Weaviate architecture.

Each node in Weaviate can function independently or collaborate with other nodes to form a decentralized network for data storage, retrieval, and search operations.

Sometimes, you may need to gather information about a given node. In this tutorial, we will explore the various methods to get the details about a given Weaviate node.

Requirements:

To follow along with this post, you need the following:

  1. An HTTP client such as cURL
  2. Python 3.10 and above
  3. A running Weaviate instance
  4. Weaviate Python Client

Get the Node Info in Weaviate Using the HTTP Endpoint

The first method that we can use to get the information about a Weaviate node is the /v1/nodes HTTP endpoint.

We can make a GET request as follows:

GET /v1/nodes

The query should return an information about the nodes as follows:

  • Name – Name of the node
  • Status – Status of the node (one of: HEALTHY, UNHEALTHY, UNAVAILABLE)
  • Version – Version of Weaviate that runs on the node
  • gitHash – Short git hash of the latest commit of Weaviate that runs on the node
  • Stats – Statistics of the node with following fields:
    • shardCount – Total number of shards on the node
    • objectCount – Total number of objects on the node
  • Shards – Array of shards with following fields:
    • Name – Name of the shard
    • Class – Name of the objects’ class stored on the shard
    • objectCount – Number of objects on the shard

The following command shows how to use cURL to request the node’s endpoint:

$ curl http://localhost:8080/v1/nodes

Ensure to replace the URL with your target Weaviate instance address.

This should return an information about the Weaviate node as follows:

Get the Node Info in Weaviate Using Python

The second and most programmatic method of fetching the information about the nodes in Weaviate is using the Python client.

Once you have the Weaviate client installed, create the client and use the code as follows:

import weaviate
client = weaviate.Client("http://localhost:8080")
nodes_status = client.cluster.get_nodes_status()
print(nodes_status)

An example output is as follows:

[{'gitHash': '36e4c04', 'name': 'weaviate-0', 'shards': [{'class': 'Winery', 'name': 'JuLaCz1mEoTt', 'objectCount': 0}, {'class': 'DatabaseServer', 'name': 'NQ0J8Ko5blmD', 'objectCount': 1}, {'class': 'Article', 'name': '1yn1LCZXVSl3', 'objectCount': 0}, {'class': 'Film', 'name': 'eaABlgYSS5t8', 'objectCount': 0}, {'class': 'Book', 'name': 'wmsbncFiAKNh', 'objectCount': 0}, {'class': 'Person', 'name': 'KMiMZXyvKmG2', 'objectCount': 0}, {'class': 'Wine', 'name': 'IIGX5Xeeb6fy', 'objectCount': 0}, {'class': 'Country', 'name': 'Spcr2wsZyR7g', 'objectCount': 0}, {'class': 'Province', 'name': 'Ihbp8FpuhjvR', 'objectCount': 0}, {'class': 'Variety', 'name': 'LKPsm3OCOXy8', 'objectCount': 0}, {'class': 'Author', 'name': 'f4tG2LhSzXfm', 'objectCount': 1}], 'stats': {'objectCount': 2, 'shardCount': 11}, 'status': 'HEALTHY', 'version': '1.19.11'}]

There you have it!

Conclusion

We explored how to show the node information in Weaviate using the HTTP endpoints and a Python client.

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