How to make a priority depending on the location of the substring?

There are two documents, with strings in ES:

- Sidorovo, Ivanovo oblast, Russia
- Ivanovo, Moscow oblast, Russia

The search is for "John". Both lines are searched. But you need to show first those results where the searched substring is closer to the beginning of the string, i.e. I want the results were as follows:
1) Ivanovo, Moscow oblast, Russia
2) Sidorovo, Ivanovo oblast, Russia

Turnkey solution you do not ask to specify the direction in which to dig.
July 8th 19 at 11:48
1 answer
July 8th 19 at 11:50
if built-in methods there, I'd hitched to the found rows "weight" equal to the position of the desired substring, and it was sorted. function name don't know, something like substr(...);
[
["Ivanovo, Moscow oblast, Russia", 1],
["Sidorovo, Ivanovo oblast, Russia", 11]
]

Find more questions by tags Elasticsearch