# Sorting of results returned by autocomplete

**URL:** <https://discuss.elastic.co/t/sorting-of-results-returned-by-autocomplete/211638>\
**Category:** Elasticsearch\
**Created:** [December 12, 2019, 11:36am UTC](https://discuss.elastic.co/t/sorting-of-results-returned-by-autocomplete/211638 "2019-12-12T11:36:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikash\_Verma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikash_verma/32/59273_2.png) [@Vikash\_Verma](https://discuss.elastic.co/u/Vikash_Verma)\
**Post date:** [December 12, 2019, 11:36am UTC](https://discuss.elastic.co/t/sorting-of-results-returned-by-autocomplete/211638/1 "2019-12-12T11:36:13Z")

</div>

Hi,

I have a simple index having following mapping:

```auto
{
 
  "mappings": {
    "_doc": {
      "dynamic": "strict",
      "properties": {
        "coordinates": {
          "type": "geo_point"
        },
        "suggest": {
          "analyzer": "standard",
          "search_analyzer": "standard",
          "type": "completion"
        }
      }
    }
  }
}

```

After inserting documents I want to retrieve results which are sorted based on the `coordinates` property.

I run following query to do the same:

```auto
{
    "suggest": {
        "region-suggest": {
            "prefix": "taj",
            "completion": {
                "field": "suggest",
                "size": 100,
                "fuzzy": {
                    "fuzziness": 0
                }
            }
        },
        "sort": [
            {
                "_geo_distance": {
                    "coordinates": [
                        {
                            "lat": 12.92,
                            "lon": 77.67
                        }
                    ],
                    "order": "desc"
                }
            }
        ]
    }
}

```

What I observer is there is no impact of `sort` field present in query.

Am I doing something wrong or sorting is not applied to autocomplete.

I did try geo context but it seems geo context can be used for filtering/boosting. I don't want any filtering. It's just that I want all the results having sorted based on the coordinate.

Any help would be appreciated.

---

<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:** [January 9, 2020, 11:36am UTC](https://discuss.elastic.co/t/sorting-of-results-returned-by-autocomplete/211638/2 "2020-01-09T11:36:13Z")

</div>

Closed on January 9, 2020, 11:36am UTC

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