Get startedGet started for free

Updating and deleting vectors

1. Updating and deleting vectors

You're doing amazing! Keep it up! In this video, we'll discuss updating and deleting vectors from our index.

2. Keeping things fresh...

Updating and deleting vectors ensures that our data remains current. In dynamic environments, data evolves rapidly, and being able to continuously integrate new values and metadata into indexes keeps our applications relevant and accurate. Tidying up our database also helps optimize performance. As our indexes grow, unused or outdated vectors can clutter our storage and slow down query processing. By removing redundant data, we streamline our operations, leading to faster responses and better resource utilization. Finally, updating and deleting vectors is essential for maintaining data integrity. Inaccurate or outdated information can compromise the reliability of our AI system. By proactively managing our vectors, we uphold the integrity of our data and the trustworthiness of our applications. Good data practices aren't only relevant to applications using vector databases, but any application that relies on data.

3. Updating vector values

Let's fetch a record from our database. We can see that the first vector value starts -0.0131, and that it has associated metadata: genre is action and year is 2023. Let's update this record to update its vector values.

4. Updating vector values

First, we call the .update() method on the index, specifying the ID of the record we wish to update, and a list of new vector values. Similar to when we ingest vectors, we need to ensure that this list is the same length as the index's dimensionality.

5. Updating vector values

Fetching the vector again, we can now see that the vector values have been updated.

6. Updating vector metadata

Now to update the metadata. We'll still use the .update() method, but this time, specify the set_metadata argument. Specifically, we changed the genre from action to comedy, kept the year information as it is, as we didn't mention it in the update, and added new metadata called 'rating' with a value of 5.

7. Updating vector metadata

And there's our updated metadata! Notice also that this didn't update the vector values, only the metadata.

8. Updating values and metadata

Finally, we can update both the values and the metadata of a vector at the same time by combining the two arguments.

9. Deleting vectors

Now, let's shift our focus to deleting vectors. We can delete vectors by-ID using the .delete() method.

10. Deleting vectors by-metadata

We can also delete vector using a metadata filter. Here, we delete vectors with the 'genre' metadata equal to 'action' - another reason to store and maintain accurate metadata!

11. Deleting vectors within a namespace

Finally, we can delete all records from a namespace using the delete_all and namespace arguments. Emptying a namespace also removes the namespace itself, so use delete_all with caution.

12. Let's practice!

Head on over to the exercises to give these a go!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.