# Elastic search query for sorting results

**URL:** <https://discuss.elastic.co/t/elastic-search-query-for-sorting-results/232740>\
**Category:** Elasticsearch\
**Created:** [May 15, 2020, 3:21am UTC](https://discuss.elastic.co/t/elastic-search-query-for-sorting-results/232740 "2020-05-15T03:21:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![angryninja](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@angryninja](https://discuss.elastic.co/u/angryninja)\
**Post date:** [May 15, 2020, 3:21am UTC](https://discuss.elastic.co/t/elastic-search-query-for-sorting-results/232740/1 "2020-05-15T03:21:26Z")

</div>

Hi,

I am trying to regular match search on a single field from the index which has **n-gram** analyzer.  
When I execute following query, the results are not sorted with string that has a perfect match on top.  
What can be done to sort a field depending upon full match to partial matches ? i.e. if I have two documents with description fields as **performance test** and **performance testing** I'd like the result with **performance test** always on top.

```auto
GET spark-index/_search 
{
  "query": {
    "match": {
      "description": "test"
    }
  }
}

```

---

<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 12, 2020, 3:21am UTC](https://discuss.elastic.co/t/elastic-search-query-for-sorting-results/232740/2 "2020-06-12T03:21:30Z")

</div>

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