# Can I see the query in the results elastic sends me?

**URL:** <https://discuss.elastic.co/t/can-i-see-the-query-in-the-results-elastic-sends-me/139523>\
**Category:** Elasticsearch\
**Created:** [July 11, 2018, 9:18am UTC](https://discuss.elastic.co/t/can-i-see-the-query-in-the-results-elastic-sends-me/139523 "2018-07-11T09:18:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yishain11](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yishain11](https://discuss.elastic.co/u/yishain11)\
**Post date:** [July 11, 2018, 9:18am UTC](https://discuss.elastic.co/t/can-i-see-the-query-in-the-results-elastic-sends-me/139523/1 "2018-07-11T09:18:08Z")

</div>

I feel like this is a dumb question, but is there a way to show the query itself in the results JSON elastic sends via search API?

For example:  
Say I'm querying index named "Movies":

`curl http://localhost:9200/Movies/_search?q=movie:matrix`

I get the normal response structure:

```
{
    "took": 1,
    "timed_out": false,
    "_shards":{
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
    },
    "hits":{
        "total" : 1,
        "max_score": 1.3
        "hits" : [
            {
                "_index" : "Movies",
                "_type" : "_doc",
                "_id" : "0",
                "_score": 1.3,
                "_source" : {
                    "movie" : "matrix",
                    "year": "1999",
                    "rating" : 4
                }
            }
        ]
    }
}

```

but is there a way to see in the response what query generated this results?

I want "movie:matrix" to appear somewhere in the results, so when I inspect the results later I would know what query created this results.

This is usefull when each doc has a lot of fields, so recovering the query is not obvious...  
Any ideas?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 11, 2018, 11:40am UTC](https://discuss.elastic.co/t/can-i-see-the-query-in-the-results-elastic-sends-me/139523/2 "2018-07-11T11:40:19Z")

</div>

Are you looking for this? [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-named-queries-and-filters.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-named-queries-and-filters.html)

---

<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 8, 2018, 11:40am UTC](https://discuss.elastic.co/t/can-i-see-the-query-in-the-results-elastic-sends-me/139523/3 "2018-08-08T11:40:19Z")

</div>

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