Skip to main content

Update 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 update objects in Weaviate, either in their entirety, or specific properties.

Requirements

To update an object, you'll need:

  1. Its id
  2. The name of its class
  3. The properties to update, in particular the entire object
Multi-tenancy

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

Update object properties

To update the values of a list of properties in an object, make a PATCH request to the /v1/objects REST API endpoint, or use the client code below. If a vectorizer is set and any text properties are updated, Weaviate will recalculate the vector embedding (unless all updated text properties are skiped).

uuid = '...'  # replace with the id of the object you want to update
client.data_object.update(
uuid=uuid,
class_name='JeopardyQuestion',
data_object={
'points': 100,
},
)

Specify the vector

If you want to update an object's vector embedding, you can specify the vector property:

client.data_object.update(
uuid=uuid,
class_name='JeopardyQuestion',
data_object={
'points': 100,
},
vector=[0.12345] * 1536
)

Update (replace) an entire object

To replace an object in its entirety, make a PUT request to the /v1/objects REST API endpoint, or use the client code below. If a vectorizer is set and any text property is replaced with a different value, Weaviate will recalculate the vector embedding (unless all updated text properties are skiped).

uuid = '...'  # the id of the object you want to replace
client.data_object.replace(
uuid=uuid,
class_name='JeopardyQuestion',
data_object={
'answer': 'Replaced',
# The other properties will be deleted
},
)

Add a new property

Weaviate does not support adding an extra property to an object if the property isn't listed in the schema class definition. You can update the values of existing class properties as seen above, or you can add the property to the class first, then update it for the desired object(s).

Delete a property

Weaviate does not yet support deleting or updating properties in the schema, but you can vote for this feature request.

To "delete" a text property, you could update it to an empty string.

To delete properties from a specific object, you can replace the object with a copy that has those properties deleted:

from typing import List
from weaviate import Client

def del_props(client: Client, uuid: str, class_name: str, prop_names: List[str]) -> None:
object_data = client.data_object.get(uuid, class_name=class_name)
for prop_name in prop_names:
if prop_name in object_data["properties"]:
del object_data["properties"][prop_name]
client.data_object.replace(object_data["properties"], class_name, uuid)


uuid = '...' # replace with the id of the object you want to delete properties from
del_props(client, uuid, 'JeopardyQuestion', ['answer'])

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