Sorting of results returned by autocomplete

Hi,

I have a simple index having following mapping:

{
 
  "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:

{
    "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.

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