Define ordering in wildcard query

In one of our use-case we're using a wildcard query on a field("cmpy") with searchQuery(val). Let's say values on different documents for "cmpy" field is "val", "1 val", "a value". Ask is, is there a way to order the results such as exactly matched text("val") should be on top & then followed by other documents? Tried "rewrite" as well but couldn't able to get "val" on top of the results.

Es_version: 6.4

You could use ngram or edge ngram based analyzers to index your field in addition to the default analyzer.
Then you can query both fields and boost if neede the field with exact match.

Some examples at:

Es_version: 6.4

It's urgent that you upgrade to at the very least 6.8 or better 7.15.0.

Got it. @dadoonet Thanks for your reply. Yes David we'll be updating our ES version to the latest in the coming months.