# \[App Search\] - Ingesting Wrong Documents Issue

**URL:** <https://discuss.elastic.co/t/app-search-ingesting-wrong-documents-issue/336951>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [June 27, 2023, 8:05am UTC](https://discuss.elastic.co/t/app-search-ingesting-wrong-documents-issue/336951 "2023-06-27T08:05:57Z")\
**Posts on this page:** 3\
**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 27, 2023, 8:05am UTC](https://discuss.elastic.co/t/app-search-ingesting-wrong-documents-issue/336951/1 "2023-06-27T08:05:57Z")

</div>

Hello, I have a case where the data that I've been ingested got detected as wrong data.

The data have been classified into MATERIAL and SERVICE type of data.

The wrong data resides under SERVICE classification with a total of 274,552 documents to be exact and it is detected that the data value has been wrongly extracted by the team.

 ![Screenshot 2023-06-27 at 3.52.17 PM](https://us1.discourse-cdn.com/elastic/original/3X/5/2/5238b352cd5f2924a3b707e2e6afe1fcced8e4de.png)

My plan was to either update the data or delete the data with SERVICE classification and ingest a new one.

I'm not sure if I can update it according to the new json file.

But I see that deleting it might be the option or maybe not.

My case would be just like this post :

> [@How to delete documents by a certain field?](https://discuss.elastic.co/t/how-to-delete-documents-by-a-certain-field/326787):
>
> Hello, I have an App Search engine and I need to delete documents in it by a certain field value. I receive JSON files that look something like this: { "entries": [{ "id": "park\_rocky-mountain", "category": "national-parks", "title": "Rocky Mountain", "nps\_link": "https://www.nps.gov/romo/index.htm", "states": ["Colorado"], "visitors": 4517585, "world\_heritage\_site": false, "location": "40.4,-105.58", "acres": 265795.…

When I reached out to the support the idea was to filter the data by query it through `item_type = SERVICE`, get the IDs and delete the documents referencing the IDs.

The above post also seems to be said the same thing :

 ![Elastic Discuss](https://us1.discourse-cdn.com/elastic/original/3X/4/d/4d56b07498f5665d5491261254f5e4dbcd398617.png)

It seems like the option is still needed to reference through the document IDs which I think it's impossible to list out 200k+ IDs here.

It's not really a good solution.

Is there any other options for me?

Or the best way is to wipe out the whole documents and ingest a new data?

If so, do I need to create a new search engine to ingest the data back or I can just simply delete all the documents in my current search engine without referencing to the IDs?

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:** [July 6, 2023, 7:39am UTC](https://discuss.elastic.co/t/app-search-ingesting-wrong-documents-issue/336951/2 "2023-07-06T07:39:09Z")

</div>

Hi @aisyaharifin :

App Search does not provide an API for deleting documents that does not depend on the ID. You will need document IDs in order to delete documents.

I think you can follow one of these two options:

- Delete the engine and re-ingest all data
- Delete the SERVICE data in the engine and re-ingest it

For option 2, you will need a script or small program that:

- Performs search using a [value filter](https://www.elastic.co/guide/en/app-search/current/filters.html#filters-value-filters) on the SERVICE field.
- For each ID retrieved on the search, do a [document delete for that ID](https://www.elastic.co/guide/en/app-search/current/documents.html#documents-delete).

The best option will depend on how long does it take to re-ingest your data vs the time you will need to create the delete script + re-ingest the data

Hope that helps!

---

<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:** [August 3, 2023, 7:40am UTC](https://discuss.elastic.co/t/app-search-ingesting-wrong-documents-issue/336951/3 "2023-08-03T07:40:06Z")

</div>

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