Skip to main content
Weaviate Docs (migrated from docs.weaviate.io) Docs

Search documentation

Type to search this documentation.

On this pageOverview

Update objects

Weaviate allows partial or complete object updates.

Additional information

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.

Python
uuid = "..."  # replace with the id of the object you want to update
JavaScript/TypeScript
const myCollection = client.collections.use('JeopardyQuestion')
Go
id := "..." // replace with the id of the object you want to update
Java
jeopardy.data.update(uuid,    u -> u.properties(Map.of("points", 100.0)));
C#
await jeopardy.Data.Replace(    uuid,    properties: new { points = 100 });

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.

Python
jeopardy = client.collections.use("JeopardyQuestion")jeopardy.data.update(    uuid=uuid,    properties={        "points": 100,    },    vector=[0.12345] * 1536)
TypeScript
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)

Coming soon

Java
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)));
C#
await jeopardy.Data.Replace(    uuid,    properties: new { points = 100 },    vectors: vector);

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

Python
jeopardy = client.collections.use("JeopardyQuestion")jeopardy.data.replace(    uuid=uuid,    properties={        "answer": "Replaced",        # The other properties will be deleted    },)
JavaScript/TypeScript
const myCollection = client.collections.use('JeopardyQuestion')
Go
id := "..." // replace with the id of the object you want to update
Java
jeopardy.data.replace(    uuid, r -> r.properties(Map.of("answer", "Replaced"    // The other properties will be deleted    )));
C#
await jeopardy.Data.Replace(    uuid,    properties: new { answer = "Replaced" }// The other properties will be deleted);

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.

Python
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
JavaScript/TypeScript
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'])
Go
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
}
Java
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));
}
C#
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);
}

Have a question or feedback? Here's how to reach us.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu