# Query works in elastic search but does not work in Kibana discover

**URL:** <https://discuss.elastic.co/t/query-works-in-elastic-search-but-does-not-work-in-kibana-discover/148120>\
**Category:** Kibana\
**Created:** [September 11, 2018, 12:20pm UTC](https://discuss.elastic.co/t/query-works-in-elastic-search-but-does-not-work-in-kibana-discover/148120 "2018-09-11T12:20:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malay\_Peaas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/malay_peaas/32/35192_2.png) [@Malay\_Peaas](https://discuss.elastic.co/u/Malay_Peaas)\
**Post date:** [September 11, 2018, 12:20pm UTC](https://discuss.elastic.co/t/query-works-in-elastic-search-but-does-not-work-in-kibana-discover/148120/1 "2018-09-11T12:20:12Z")

</div>

I've an index of dummy logs having a field called "sequence" I want to sort on basis of this field, so **while getting the data in ElasticSearch** I use the following query

```
{
  "query": {
    "match": {
      "trace_id": "5f6e223c-b5ac-11e8-96f8-529269fb1459"
    }
  },
  "sort": [
    {
      "sequence": {
        "order": "asc"
      }
    }
  ]
}

```

**This works perfectly fine** and gives me docs in ascending order. But when I put same query in Kibana's discover tab's filter using edit query DSL it **only searches for docs with trace\_id = 5f6e223c-b5ac-11e8-96f8-529269fb1459** and **does not sort these docs**.

Can anyone explain what I am doing wrong here?

Thanks,  
Malay M

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [September 11, 2018, 7:07pm UTC](https://discuss.elastic.co/t/query-works-in-elastic-search-but-does-not-work-in-kibana-discover/148120/2 "2018-09-11T19:07:08Z")

</div>

The "edit query DSL" section of the filter editor only accepts the query portion of the search request body, you can't specify a sort in there.

To sort, you need to add `sequence` as a column in the doc table and click on the arrow in its column header.

---

<div class="post-metadata">

**Author:** ![Malay\_Peaas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/malay_peaas/32/35192_2.png) [@Malay\_Peaas](https://discuss.elastic.co/u/Malay_Peaas)\
**Post date:** [September 12, 2018, 5:16am UTC](https://discuss.elastic.co/t/query-works-in-elastic-search-but-does-not-work-in-kibana-discover/148120/3 "2018-09-12T05:16:02Z")

</div>

I see, I did the way you suggested and it works , but when I initially tried it I thought it was a hack and not the right way to do it. 😅 Thanks for the help.

---

<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:** [October 10, 2018, 5:16am UTC](https://discuss.elastic.co/t/query-works-in-elastic-search-but-does-not-work-in-kibana-discover/148120/4 "2018-10-10T05:16:10Z")

</div>

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