Weaviate is an open-source knowledge graph and vector search engine developed by Semantria. It uses machine learning techniques to organize and retrieve data based on its semantic meaning.
Weaviate objects provide a structured way to represent and organize data in a knowledge graph, enabling advanced search and retrieval capabilities based on the semantic understanding of the information.
Weaviate List Objects – HTTP
The API endpoint is the most common way of fetching objects in a Weaviate cluster. The following shows the HTTP method and URL to query the Weaviate objects.
GET /v1/objects
The request returns all the objects in all the Weaviate classes. However, the output is limited to 25 objects per output.
Query Parameters
You can also include other parameters in the query which govern how the operation of the query and the resulting output.
The parameters are as expressed below:
- Class - List objects by class using the class name.`
- Limit - The maximum number of data objects to return. Default 25.
- Offset - The offset of objects returned (the starting index of the returned objects). Use in conjunction with limit.
- After - ID of the object after which objects are to be listed.
- Include - Include additional information, such as classification info. Allowed values include classification, vector, and featureProjection.
- Sort - Name of the property to sort by - i.e., sort=city
- Order - Order in which to sort by. Possible values: asc (default) and desc.
An example usage of the above query parameters is as shown below:
GET /v1/objects?class={ClassName}&limit={limit}&include={include}
In this case, the above query specifies the class name, limit, the information to include and more.
You can also performing paging of the objects using the limit and offset parameters as shown:
GET /v1/objects?class=ClassName&limit=10
This should return the first ten objects from the specified class. To fetch the next ten objects, you can use the offset parameter:
GET /v1/objects?class=MyClass&limit=10&offset=10
Weaviate List Objects – Python
You can also use the Weaviate Python client to list all the objects in the Weaviate class as shown:
>>> import weaviate
>>> client = weaviate.Client("http://localhost:8080")
>>> all_objects = client.data_object.get(class_name="ClassName")
>>> print(all_objects)
This should return all the objects in the specified class.
Conclusion
In this tutorial, we learned how to get a list of all the objects in various Weaviate classes, including limiting output, paging, and more.