Skip to main content

Update objects

Weaviate allows partial or complete object updates.

Additional information
  • Partial updates use PATCH requests to the /v1/objects REST API endpoint under the hood.

  • Complete updates use PUT requests to the /v1/objects REST API endpoint under the hood.

  • Updates that include a vector property will recalculate the vector embedding (unless all updated text properties are skipped).

  • To update objects, you must provide the collection name, id and properties to update.

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


    Collection (class) Name in Object CRUD Operations

    Collections act like namespaces, so two different collections could have duplicate IDs between them.


    Prior to Weaviate v1.14 you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate v2.0.0.

    Starting in v1.20, you can have multi-tenant datasets. When multi-tenancy is enabled, the tenant name is required.

    Always include the collection name, and, when enabled, the tenant name.

Update object properties

Update one or more properties by providing the collection name, id and properties to update.

uuid = "..."  # replace with the id of the object you want to update

jeopardy = client.collections.get("JeopardyQuestion")
jeopardy.data.update(
uuid=uuid,
properties={
"points": 100,
}
)

Update object vector

The object vector can also be updated similarly to properties. For named vectors, provide the data as a dictionary/map similarly to the object creation.

jeopardy = client.collections.get("JeopardyQuestion")
jeopardy.data.update(
uuid=uuid,
properties={
"points": 100,
},
vector=[0.12345] * 1536
)

Replace an entire object

The entire object can be replaced by providing the collection name, id and the new object.

jeopardy = client.collections.get("JeopardyQuestion")
jeopardy.data.replace(
uuid=uuid,
properties={
"answer": "Replaced",
# The other properties will be deleted
},
)

Delete a property

Deleting or updating properties in the collection definition is not yet supported.

At object level, you can replace the object with a copy that has those properties deleted, or set to "" for text properties.

from typing import List
from weaviate import WeaviateClient

def del_props(client: WeaviateClient, uuid_to_update: str, collection_name: str, prop_names: List[str]) -> None:
collection = client.collections.get(collection_name)

# fetch the object to update
object_data = collection.query.fetch_object_by_id(uuid_to_update)
properties_to_update = object_data.properties

# remove unwanted properties
for prop_name in prop_names:
if prop_name in properties_to_update:
del properties_to_update[prop_name]

# replace the properties
collection.data.replace(
uuid=uuid_to_update,
properties=properties_to_update
)


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

Questions and feedback

If you have any questions or feedback, let us know in our user forum.