Skip to main content

Read objects

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

Overview

This page will show you how to read individual objects in Weaviate.

Requirements

To read a specific object from a collection, you'll need its id and class name.

Why specify the class name?
Class Name in Object CRUD Operations

Prior to Weaviate v1.14 it was possible to manipulate objects using only their ID without specifying the class name. This way is still supported for backward compatibility, but is considered deprecated now. Avoid using the deprecated endpoints, as they will be removed with Weaviate v2.0.0.


The reason for the deprecation is that classes generally act like namespaces, therefore duplicate IDs are possible.


Additionally, where multi-tenancy (available from v1.20.0) is enabled, the tenant name is required.


It is thus recommended to always include the class name when manipulating objects.

Multi-tenancy

For classes where multi-tenancy is enabled, you will also need to specify the tenant name. See Manage data: multi-tenancy operations for details on how.

Get object by id

To retrieve an object by id, make a GET request to the /v1/objects REST API endpoint, or use the client code below. If the id doesn't exist in the specified class, a 404 error will be returned.

data_object = client.data_object.get_by_id(
'00ff6900-e64f-5d94-90db-c8cfa3fc851b',
class_name='JeopardyQuestion',
)

print(json.dumps(data_object, indent=2))

Retrieve the object vector

To retrieve the object vector, set the vector parameter:

data_object = client.data_object.get_by_id(
'00ff6900-e64f-5d94-90db-c8cfa3fc851b',
class_name='JeopardyQuestion',
with_vector=True
)

print(json.dumps(data_object, indent=2))

More Resources

For additional information, try these sources.

  1. Frequently Asked Questions
  2. Weaviate Community Forum
  3. Knowledge base of old issues
  4. Stackoverflow
  5. Weaviate slack channel