# Can not remove hits.hits.sort field from response of /\_search request with sort

**URL:** <https://discuss.elastic.co/t/can-not-remove-hits-hits-sort-field-from-response-of-search-request-with-sort/204992>\
**Category:** Elasticsearch\
**Created:** [October 24, 2019, 3:50am UTC](https://discuss.elastic.co/t/can-not-remove-hits-hits-sort-field-from-response-of-search-request-with-sort/204992 "2019-10-24T03:50:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![muziyoshiz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muziyoshiz/32/56486_2.png) [@muziyoshiz](https://discuss.elastic.co/u/muziyoshiz)\
**Post date:** [October 24, 2019, 3:50am UTC](https://discuss.elastic.co/t/can-not-remove-hits-hits-sort-field-from-response-of-search-request-with-sort/204992/1 "2019-10-24T03:50:27Z")

</div>

Hello Elasticsearch Team,

In our use case, we want to get only document IDs of the matched documents as a result of search API `/_search`.

But when I call search API with a query including "sort" field, the response contains unnecessary hits.hits.sort field as follows.

```auto
{
  "took": 6,
  "timed_out": false,
  "_shards": {
    "total": 6,
    "successful": 6,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": null,
    "hits": [
      {
        "_index": "example1",
        "_type": "_doc",
        "_id": "12345",
        "_score": null,
        "sort": [
          "Unnecessary keyword value",
          "12345"
        ]
      }
    ]
  }
}

```

`"_source":false` was ignored for the hits.hits.sort field.  
In our use case, the keyword field for sort may contain long keyword. So it consumes Java heap space uselessly.

Can I remove hits.hits.sort field itself or the keyword text in the field by any option?

Thanks.

---

<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:** [October 24, 2019, 8:23am UTC](https://discuss.elastic.co/t/can-not-remove-hits-hits-sort-field-from-response-of-search-request-with-sort/204992/2 "2019-10-24T08:23:33Z")

</div>

Welcome! I don't think you can. That being said I don't think that displaying 10 sort values is the problem.

You should read [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#\_memory\_considerations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_memory_considerations)

It says that you are loading in memory all the sort values. Even though you are displaying only 10 afterwards.

May be using index sorting could help? See [https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-index-sorting.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-index-sorting.html)

---

<div class="post-metadata">

**Author:** ![muziyoshiz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muziyoshiz/32/56486_2.png) [@muziyoshiz](https://discuss.elastic.co/u/muziyoshiz)\
**Post date:** [October 24, 2019, 8:51am UTC](https://discuss.elastic.co/t/can-not-remove-hits-hits-sort-field-from-response-of-search-request-with-sort/204992/3 "2019-10-24T08:51:28Z")

</div>

Thank you very much!

Sorry for my incomplete explanation. we used bigger size than default value (10).  
So the size of the response came to an issue.

After my post, I found filter\_path parameter. It may be the solution for what we wanted to do.  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering)

---

<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:** [October 24, 2019, 2:34pm UTC](https://discuss.elastic.co/t/can-not-remove-hits-hits-sort-field-from-response-of-search-request-with-sort/204992/4 "2019-10-24T14:34:27Z")

</div>

May be but the filtering will not happen early though. So big objects will still being built in memory.

---

<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:** [November 21, 2019, 2:34pm UTC](https://discuss.elastic.co/t/can-not-remove-hits-hits-sort-field-from-response-of-search-request-with-sort/204992/5 "2019-11-21T14:34:32Z")

</div>

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