# CRUD App Search via API using Python Client

**URL:** <https://discuss.elastic.co/t/crud-app-search-via-api-using-python-client/336656>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [June 22, 2023, 8:58am UTC](https://discuss.elastic.co/t/crud-app-search-via-api-using-python-client/336656 "2023-06-22T08:58:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aisyaharifin](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@aisyaharifin](https://discuss.elastic.co/u/aisyaharifin)\
**Post date:** [June 22, 2023, 8:58am UTC](https://discuss.elastic.co/t/crud-app-search-via-api-using-python-client/336656/1 "2023-06-22T08:58:55Z")

</div>

Hello,

I have a problem where the data I've ingested, one of the attribute column is a wrong data.

The data ingested is around 200k+ documents.

I'm trying to update the whole data by API by following this documentation :

> **[Connecting | enterprise-search-python \[8.8\] | Elastic](https://www.elastic.co/guide/en/enterprise-search-clients/python/8.8/connecting.html)**

But I'm stuck at Authenticating with App Search.

 ![Screenshot 2023-06-22 at 4.55.54 PM](https://us1.discourse-cdn.com/elastic/original/3X/c/4/c40b08d23d0c1f1ec64e2c9daefaff5a983bdf03.png)

The error I've got is this :

 ![Screenshot 2023-06-22 at 4.50.47 PM](https://us1.discourse-cdn.com/elastic/original/3X/2/4/2411e27662107cdcf74b903f6e4c431ae1a839fb.png)

Appreciate if anyone could help me with this, thank you.

---

<div class="post-metadata">

**Author:** ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)\
**Post date:** [June 22, 2023, 10:27am UTC](https://discuss.elastic.co/t/crud-app-search-via-api-using-python-client/336656/2 "2023-06-22T10:27:09Z")

</div>

Hi @aisyaharifin !

The documentation is incorrect, we'll make sure to change that.

Please try the following:

```python
# Creating a Signed Search Key on the server side...
signed_search_key = server_side.create_signed_search_key(
    api_key="<private api key value>",
    api_key_name="<private api key name>",
    search_fields={
        "body": {}
    }
)

```

You will need to get the [private API key](https://www.elastic.co/guide/en/app-search/current/authentication.html#authentication-api-keys) included in your deployment, or create a new one to fill out the key name and value.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![aisyaharifin](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@aisyaharifin](https://discuss.elastic.co/u/aisyaharifin)\
**Post date:** [June 23, 2023, 2:36am UTC](https://discuss.elastic.co/t/crud-app-search-via-api-using-python-client/336656/3 "2023-06-23T02:36:52Z")

</div>

Hi @Carlos_D ,

Thank you for your reply.

I've already tried and it works but then I couldn't do any request.

 ![Screenshot 2023-06-23 at 10.15.35 AM](https://us1.discourse-cdn.com/elastic/original/3X/9/d/9d37653f8e42067df5ae3f79a77bbc190be35dc5.png)

So I've tried to directly connect to App Search by using this reference :

> <https://github.com/elastic/enterprise-search-python/blob/main/docs/guide/app-search-api.asciidoc#app-search-initializing>

It seems like the `http_auth` is not working so I've tried used the `bearer_auth`, but then I still couldn't do any request.

 ![http_auth error](https://us1.discourse-cdn.com/elastic/original/3X/7/8/784dd1558f8a18932af02cfe4e51ec4f17c4a29e.png)  
 ![request error](https://us1.discourse-cdn.com/elastic/original/3X/d/1/d17a9c3cab6759a13dcfc530e413ec89ddc2e5a6.png)

My main problem now is the data I've ingested, one of the attribute column is a wrong data.

The data ingested is around 200k+ documents.

Do you have any workaround option on how can I fix the wrong data by updating the new one?

Currently I've been trying to do it through API, but it seems like the documentation is wrong?

Do you have any proper guideline for me?

Thank you, truly appreciate your help.

---

<div class="post-metadata">

**Author:** ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)\
**Post date:** [July 3, 2023, 3:57pm UTC](https://discuss.elastic.co/t/crud-app-search-via-api-using-python-client/336656/4 "2023-07-03T15:57:31Z")

</div>

Hi @aisyaharifin :

A 403 error means that you don't have permissions. Have you checked that the API key value is correct? You should be able to use `bearer_auth` with the private API key value. There is a private API key defined by default, and you can create a new one.

Can you please include the python code you're using for connecting?

Regarding your main problem, do you need to update a single field for your documents? In that case, you could use a [partial update](https://www.elastic.co/guide/en/app-search/current/documents.html#documents-partial) to just update the field you need.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 31, 2023, 3:58pm UTC](https://discuss.elastic.co/t/crud-app-search-via-api-using-python-client/336656/5 "2023-07-31T15:58:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
