# Hi, I want to ask a thing in Elasticsearch. If I want to ignore a document based on a certain field value, how can I do that in the flatmap function of javascript

**URL:** <https://discuss.elastic.co/t/hi-i-want-to-ask-a-thing-in-elasticsearch-if-i-want-to-ignore-a-document-based-on-a-certain-field-value-how-can-i-do-that-in-the-flatmap-function-of-javascript/275401>\
**Category:** Elasticsearch\
**Created:** [June 9, 2021, 8:43am UTC](https://discuss.elastic.co/t/hi-i-want-to-ask-a-thing-in-elasticsearch-if-i-want-to-ignore-a-document-based-on-a-certain-field-value-how-can-i-do-that-in-the-flatmap-function-of-javascript/275401 "2021-06-09T08:43:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![appydam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/appydam/32/89306_2.png) [@appydam](https://discuss.elastic.co/u/appydam)\
**Post date:** [June 9, 2021, 8:43am UTC](https://discuss.elastic.co/t/hi-i-want-to-ask-a-thing-in-elasticsearch-if-i-want-to-ignore-a-document-based-on-a-certain-field-value-how-can-i-do-that-in-the-flatmap-function-of-javascript/275401/1 "2021-06-09T08:43:47Z")

</div>

Hi, I want to ask a thing in Elasticsearch. If I want to ignore a document based on a certain field value, how can I do that in the flatmap function of javascript

```auto
const body = datajson.flatMap((doc: Resource) => [
    { index: { _index: index, _id: doc.id } },
    {
      title: doc.title,
      shortDescription: doc.shortDescription,
      description: doc.description,
    }
]))

```

In the document, there is a field called status which is 'active' or 'inactive'.  
I want to ignore the documents whose status are inactive

---

<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 7, 2021, 8:44am UTC](https://discuss.elastic.co/t/hi-i-want-to-ask-a-thing-in-elasticsearch-if-i-want-to-ignore-a-document-based-on-a-certain-field-value-how-can-i-do-that-in-the-flatmap-function-of-javascript/275401/2 "2021-07-07T08:44:13Z")

</div>

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