Skip to main content
Go to documentation:
⌘U
Weaviate Database

Develop AI applications using Weaviate's APIs and tools

Deploy

Deploy, configure, and maintain Weaviate Database

Query Agent

Run agentic search over your Weaviate Cloud collections

Weaviate Cloud

Manage and scale Weaviate in the cloud

Engram

Persistent memory for LLM agents and applications

Additional resources

Integrations
Weaviate Academy

Need help?

Weaviate LogoAsk AI Assistant⌘K
Support
Community Forum
Contributor guide

Update objects

Weaviate allows partial or complete object updates.

Additional information
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​

This operation replaces the entire value of the specified properties only, leaving the unspecified properties. Provide the collection name, the object id, and the properties to update.

If you update the value of a previously vectorized property, Weaviate re-vectorizes the object automatically. This also reindexes the updated object.

However, if you add a new property to your collection definition, Weaviate only vectorizes the new objects. Weaviate doesn't re-vectorize and re-index existing objects when a new property is defined, only when an existing property is updated.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
uuid = "..."  # replace with the id of the object you want to update

jeopardy = client.collections.use("JeopardyQuestion")
jeopardy.data.update(
uuid=uuid,
properties={
"points": 100,
}
)
const myCollection = client.collections.use('JeopardyQuestion') 
const response = await myCollection.data.update({
id: 'ed89d9e7-4c9d-4a6a-8d20-095cb0026f54',
properties: {
'points': 100,
},
})

console.log(response)
id := "..." // replace with the id of the object you want to update
client.Data().Updater().
WithMerge(). // merges properties into the object
WithID(id).
WithClassName("JeopardyQuestion").
WithProperties(map[string]interface{}{
"points": 100,
}).
Do(ctx)
questions := client.Collections.Use("JeopardyQuestion")
id := uuid.MustParse("a3b4c5d6-e7f8-4a9b-8c0d-1e2f3a4b5c6d") // The object to update.

err := questions.Data.Update(ctx, data.Object{
UUID: &id,
Properties: map[string]any{
"points": 100,
},
})
if err != nil {
// handle error
panic(err)
}
jeopardy.data.update(uuid,
u -> u.properties(Map.of("points", 100.0))
);
await jeopardy.Data.Replace(
uuid,
properties: new { 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.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
jeopardy = client.collections.use("JeopardyQuestion")
jeopardy.data.update(
uuid=uuid,
properties={
"points": 100,
},
vector=[0.12345] * 1536
)
const jeopardy = client.collections.use('JeopardyQuestion')
const response = await jeopardy.data.update({
id: 'ed89d9e7-4c9d-4a6a-8d20-095cb0026f54',
vectors: Array(1536).fill(0.12345), // new vector value
})

console.log(response)
questions := client.Collections.Use("JeopardyQuestion")
id := uuid.MustParse("c4d5e6f7-a8b9-4c0d-8e1f-2a3b4c5d6e7f") // The object to update.

err := questions.Data.Update(ctx, data.Object{
UUID: &id,
Vectors: []types.Vector{
{Name: "default", Single: []float32{0.12345, 0.6789, 0.9876}},
},
})
if err != nil {
// handle error
panic(err)
}
float[] vector = new float[384];
Arrays.fill(vector, 0.12345f);

jeopardy.data.update(uuid, u -> u.properties(Map.of("points", 100.0))
.vectors(Vectors.of(vector))
);
await jeopardy.Data.Replace(
uuid,
properties: new { points = 100 },
vectors: vector
);

Replace an entire object​

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

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
jeopardy = client.collections.use("JeopardyQuestion")
jeopardy.data.replace(
uuid=uuid,
properties={
"answer": "Replaced",
# The other properties will be deleted
},
)
const myCollection = client.collections.use('JeopardyQuestion') 
const response = await myCollection.data.replace({
id: 'ed89d9e7-4c9d-4a6a-8d20-095cb0026f54',
properties: {
'answer': 'Replaced',
// The other properties will be deleted
},
})

console.log(response)
id := "..." // replace with the id of the object you want to update
client.Data().Updater(). // replaces the entire object
WithID(id).
WithClassName("JeopardyQuestion").
WithProperties(map[string]interface{}{
"answer": "Replaced",
// The other properties will be deleted
}).
Do(ctx)
questions := client.Collections.Use("JeopardyQuestion")
id := uuid.MustParse("e1f2a3b4-c5d6-4e7f-8a9b-4c5d6e7f8a9b") // The object to replace.

err := questions.Data.Replace(ctx, data.Object{
UUID: &id,
Properties: map[string]any{
"answer": "Replaced",
// The other properties are deleted.
},
})
if err != nil {
// handle error
panic(err)
}
jeopardy.data.replace(
uuid, r -> r.properties(Map.of("answer", "Replaced"
// The other properties will be deleted
)));
await jeopardy.Data.Replace(
uuid,
properties: new { 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.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
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.use(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"])
async function deleteProperties(client: WeaviateClient, uuidToUpdate: string, collectionName: string, propNames: string[]) {
const collection = client.collections.use(collectionName);
const objectData = await collection.query.fetchObjectById(uuidToUpdate);
const propertiesToUpdate = objectData?.properties;

if (propertiesToUpdate) {
for (let propName of propNames) {
if (propName in propertiesToUpdate) {
delete propertiesToUpdate[propName];
}
}

let result = await collection.data.replace({
id: uuidToUpdate,
properties: propertiesToUpdate
})
}
}

let id = 'ed89d9e7-4c9d-4a6a-8d20-095cb0026f54'
deleteProperties(client, id, 'JeopardyQuestion', ['answer'])
delProps := func(uuid, className string, propNames ...string) (bool, error) {
objs, err := client.Data().ObjectsGetter().WithID(uuid).WithClassName(className).Do(ctx)
if err != nil {
return false, err
}
if objs == nil || len(objs) == 0 {
return false, fmt.Errorf("object with id: %v not found", uuid)
}
if objs[0].Properties == nil {
return false, fmt.Errorf("object with id: %v has no properties", uuid)
}
properties := objs[0].Properties.(map[string]interface{})
for _, propName := range propNames {
delete(properties, propName)
}
err = client.Data().Updater().
WithID(uuid).
WithClassName(className).
WithProperties(properties).
Do(ctx)
return err == nil, err
}

id := "..." // replace with the id of the object you want to update
isUpdated, err := delProps(id, "JeopardyQuestion", "answer")
questions := client.Collections.Use("JeopardyQuestion")
id := uuid.MustParse("b1e2d3c4-a5f6-4e7d-8c9b-1a2b3c4d5e6f") // The object to update.
propNames := []string{"answer"} // The properties to delete.

// Fetch the object.
response, err := questions.Query.OverAll(ctx, query.OverAll{
Filter: &filter.Cond{Target: filter.UUID, Operator: filter.Equal, Value: id},
})
if err != nil {
// handle error
panic(err)
}
if len(response.Objects) == 0 {
panic("object not found")
}

// Remove the unwanted properties.
properties := response.Objects[0].Properties
for _, name := range propNames {
delete(properties, name)
}

// Replace the object with the remaining properties.
err = questions.Data.Replace(ctx, data.Object{UUID: &id, Properties: properties})
if err != nil {
// handle error
panic(err)
}
  private static void delProps(WeaviateClient client, String uuidToUpdate, String collectionName,
List<String> propNames) throws IOException {
CollectionHandle<Map<String, Object>> collection = client.collections.use(collectionName);

// fetch the object to update
Optional<WeaviateObject<Map<String, Object>>> objectDataOpt =
collection.query.fetchObjectById(uuidToUpdate);
if (objectDataOpt.isEmpty()) {
return;
}
Map<String, Object> propertiesToUpdate = new HashMap<>(objectDataOpt.get().properties());

// remove unwanted properties
for (String propName : propNames) {
propertiesToUpdate.remove(propName);
}

// replace the properties
collection.data.replace(uuidToUpdate, r -> r.properties(propertiesToUpdate));
}

delProps(client, uuid, "JeopardyQuestion", List.of("answer"));
private static async Task DelProps(
WeaviateClient client,
Guid uuidToUpdate,
string collectionName,
IEnumerable<string> propNames
)
{
var collection = client.Collections.Use(collectionName);

// fetch the object to update
var objectData = await collection.Query.FetchObjectByID(uuidToUpdate);
if (objectData?.Properties is not IDictionary<string, object> propertiesToUpdate)
{
return;
}

// remove unwanted properties
foreach (var propName in propNames)
{
propertiesToUpdate.Remove(propName);
}

// replace the properties
await collection.Data.Replace(uuidToUpdate, propertiesToUpdate);
}


await DelProps(client, uuid, "JeopardyQuestion", new[] { "answer" });

Questions and feedback​