# Unable to get field check on First insertion

**URL:** https://forum.weaviate.io/t/unable-to-get-field-check-on-first-insertion/9703
**Category:** General
**Created:** [January 13, 2025, 12:22pm UTC](https://forum.weaviate.io/t/unable-to-get-field-check-on-first-insertion/9703 "2025-01-13T12:22:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Muhammad\_Ashir](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/muhammad_ashir/32/2644_2.png) [@Muhammad\_Ashir](https://forum.weaviate.io/u/Muhammad_Ashir)
#### Post date: [January 13, 2025, 12:22pm UTC](https://forum.weaviate.io/t/unable-to-get-field-check-on-first-insertion/9703/1 "2025-01-13T12:22:56Z")

</div>

I am trying to create a collection which totally works fine like this

```auto
try:
        collection_name = generate_collection_name(request.id)
        client.collections.create(
            collection_name,
            vectorizer_config=[
                Configure.NamedVectors.text2vec_transformers(
                    name="filename", source_properties=["filecontent"]
                )
            ],
        )

```

But when I try to insert I need to check before if there is an object exist and when I filter it by filename then it says filename is not available my code is

```auto
# Query to check if the embedding already exists
        existing_embeddings = collection.query.fetch_objects(
            filters=Filter.by_property("filename").equal(request.id),limit=1)
        
        # If embedding exists, delete it
        if len(existing_embeddings.objects)>0:
            print(f"Existing embedding found. Deleting: {request.id}")
            collection.data.delete_many(
                where=Filter.by_property("filename").equal(request.id)
            )
        
        # Add the new embedding
        print(f"Adding new embedding: {request.id}")
        with collection.batch.dynamic() as batch:
            batch.add_object(properties=data_row)
        

```

checking if exist then delete otherwise add, BUT on the very FIRST INSERTION it says filename not found as property but then one more thing if I even add filename in properties at creation time of class like this

```auto
Configure.NamedVectors.text2vec_transformers(
                    name="vector_data", source_properties=["filename","filecontent"]
                )

```

I get same error is there any way to sort and check with filter by at start plus I can not use uids because I have to fetch my collection at a time against file ids and then obviously i will have to store that as well.

---

<div class="post-metadata">

### Author: ![Muhammad\_Ashir](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/muhammad_ashir/32/2644_2.png) [@Muhammad\_Ashir](https://forum.weaviate.io/u/Muhammad_Ashir)
#### Post date: [January 13, 2025, 12:44pm UTC](https://forum.weaviate.io/t/unable-to-get-field-check-on-first-insertion/9703/2 "2025-01-13T12:44:23Z")

</div>

fixed, using collection schema.

---

<div class="post-metadata">

### Author: ![Shahin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shahin/32/7944_2.png) [@Shahin](https://forum.weaviate.io/u/Shahin)
#### Post date: [January 14, 2025, 12:25pm UTC](https://forum.weaviate.io/t/unable-to-get-field-check-on-first-insertion/9703/3 "2025-01-14T12:25:44Z")

</div>

Hi @Muhammad_Ashir,

There is a check on objects which can be beneficial for you by using .exists() in the client:

> **[Read objects | Weaviate](https://weaviate.io/developers/weaviate/manage-data/read#check-object-existence)**
>
> Instead of querying your database, you can use an ID to retrieve individual objects.

`<VAR> = <COL_NAME>.data.exists(object_uuid)`

Hope this helps!

Regards,  
Mohamed Shahin,  
Weaviate Support Engineer
