How to suggest by name sort by count field

I'm using elasticsearch completion suggester to search and suggest keywords while user typing. It works fine but I also want to sort the results by count field.
As I know I can't pass a field as the weight parameter. So how can I search by text field and sort by long field with elasticsearch just like in Instagram?

I also want to show only top 5 suggestion but size parameter also doesn't work

Mapping:

{
	"mappings":
	{
	 "doc": 
	 {
		"properties":
			{
				"keyword_name":{ "type" : "completion" },
				"keyword_user_count":{ "type" : "long" }
			} 
	 }			
	}
}

I've tried this but Sort doesn't change the result.

    "sort" : [
        { "keyword_user_count" : {"order" : "asc"}}
 
    ],
    "suggest": {
        "keyword-suggest" : {
            "prefix" : "key", 
            "completion" : { 
                "field" : "keyword_name" 
            }
        }
    }
     
}

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