# Add hits.total to field in Elasticsearch filter

**URL:** <https://discuss.elastic.co/t/add-hits-total-to-field-in-elasticsearch-filter/132413>\
**Category:** Logstash\
**Created:** [May 18, 2018, 4:27am UTC](https://discuss.elastic.co/t/add-hits-total-to-field-in-elasticsearch-filter/132413 "2018-05-18T04:27:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crux](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/crux/32/21918_2.png) [@crux](https://discuss.elastic.co/u/crux)\
**Post date:** [May 18, 2018, 4:27am UTC](https://discuss.elastic.co/t/add-hits-total-to-field-in-elasticsearch-filter/132413/1 "2018-05-18T04:27:16Z")

</div>

I can’t seem to find a good way to get `hits.total` from the Elasticsearch response in my logstash pipeline. I’m really looking for a yes or no answer, so I have size set to 0. If I have a document that looks like this:

```auto
curl -s -H 'content-type: application/json' http://172.17.0.5:9200/myindex/_search?pretty -d '
{
  "size": 0,
  "query": {
    "term": {
      "foo": "bar"
    }
  }
}'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.0,
    "hits" : []
  }
}

```

I’m not able to copy any of the events out of the document. The `Field` setting allows me to grab events from the `hits` field and the `docinfo_field` setting allows me to grab the document info, but neither allows me to copy `hits.total`, `took`, `timed_out`, or any of the `_shard` fields.

Any ideas? Thanks ahead of time.

---

<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:** [June 15, 2018, 4:27am UTC](https://discuss.elastic.co/t/add-hits-total-to-field-in-elasticsearch-filter/132413/2 "2018-06-15T04:27:17Z")

</div>

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