# Creating an object avoiding duplicates

**URL:** <https://forum.weaviate.io/t/creating-an-object-avoiding-duplicates/2324>\
**Category:** General\
**Created:** [May 14, 2024, 3:01pm UTC](https://forum.weaviate.io/t/creating-an-object-avoiding-duplicates/2324 "2024-05-14T15:01:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjalex](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/rjalex/32/807_2.png) [@rjalex](https://forum.weaviate.io/u/rjalex)\
**Post date:** [May 14, 2024, 3:01pm UTC](https://forum.weaviate.io/t/creating-an-object-avoiding-duplicates/2324/1 "2024-05-14T15:01:46Z")

</div>

What is the best approach to avoid creating an object which has identical contents?

Experimenting with a simple data.insert will happily add a new object (and will assign it a diffferent UUID of course).

Do I need to first attempt a fetch and only if it fails create?

Can I use a string with the weaviate.util.generate\_uuid5 function to generate a deterministic UUID and use that to quickly see if I already have that value in the collection?

Thanks for any suggestion

Thank you

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [May 14, 2024, 3:05pm UTC](https://forum.weaviate.io/t/creating-an-object-avoiding-duplicates/2324/2 "2024-05-14T15:05:03Z")

</div>

hi @rjalex !

That’s right. If you have an id for that object, you can pass over a generated UUID based on that ID (or unique string) so it can generate deterministic IDS.

Here we have a doc on that:

> **[Create objects | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/manage-data/create#generate-deterministic-ids)**
>
> The examples on this page demonstrate how to create individual objects in Weaviate.

Let me know if this helps!

Thanks!

---

<div class="post-metadata">

**Author:** ![rjalex](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/rjalex/32/807_2.png) [@rjalex](https://forum.weaviate.io/u/rjalex)\
**Post date:** [May 14, 2024, 3:07pm UTC](https://forum.weaviate.io/t/creating-an-object-avoiding-duplicates/2324/3 "2024-05-14T15:07:20Z")

</div>

Thanks @DudaNogueira so the best way to avoid inserting duplicates is to use a deterministic UUID and first fetch then insert, right?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [May 14, 2024, 8:35pm UTC](https://forum.weaviate.io/t/creating-an-object-avoiding-duplicates/2324/4 "2024-05-14T20:35:27Z")

</div>

hi @rjalex !  
If you provide an existing UUID while ingesting an object, Weaviate will update it for you.

So no need to fetch it first, unless you don’t want the object updated (considering you have a different property value).

A fairly common mistake I have seen is when a user wrongfully passes the same text to generate the UUID while ingesting (like a wrong variable, for example) for all objects, resulting in the same UUID.

On that scenario, after the import, your collection will have only one object 🙀

So basically, the first object gets created, and the subsequent ones are only updating that same object, as it is passing the same UUID 🙈

---

<div class="post-metadata">

**Author:** ![rjalex](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/rjalex/32/807_2.png) [@rjalex](https://forum.weaviate.io/u/rjalex)\
**Post date:** [May 15, 2024, 4:36am UTC](https://forum.weaviate.io/t/creating-an-object-avoiding-duplicates/2324/5 "2024-05-15T04:36:32Z")

</div>

That is awesome and simplifies inserting a lot. Thanks
