# How to Get a specific field in query elasticsearch, and write it somewhere

**URL:** <https://discuss.elastic.co/t/how-to-get-a-specific-field-in-query-elasticsearch-and-write-it-somewhere/178451>\
**Category:** Elasticsearch\
**Created:** [April 25, 2019, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-a-specific-field-in-query-elasticsearch-and-write-it-somewhere/178451 "2019-04-25T12:06:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matheusribeirogarcia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matheusribeirogarcia/32/44363_2.png) [@matheusribeirogarcia](https://discuss.elastic.co/u/matheusribeirogarcia)\
**Post date:** [April 25, 2019, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-a-specific-field-in-query-elasticsearch-and-write-it-somewhere/178451/1 "2019-04-25T12:06:47Z")

</div>

Basically I have an elasticsearch index that contains logs from postfix, i've made an query that gets all documents that contains the value I want, like this:

```
GET postfix-logs/_search
{
   "query": {
        "match_phrase": {
          "postfix_smtp_response": "*said: 550*"
        }
    }
}

```

And with that, I want to get the field "postfix\_to" that it is in the same document, and write it in some type of text, like CSV or txt.

That writting would be something that runs in a timeline, for example, every single 3 days, it writes the file.

Thanks in advance.

---

<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:** [May 23, 2019, 12:06pm UTC](https://discuss.elastic.co/t/how-to-get-a-specific-field-in-query-elasticsearch-and-write-it-somewhere/178451/2 "2019-05-23T12:06:52Z")

</div>

Closed on May 23, 2019, 12:06pm UTC

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