M
M
Malin2016-06-26 16:08:39
elasticsearch
Malin, 2016-06-26 16:08:39

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

There are two documents with strings in ES:
- Sidorovo, Ivanovskaya Oblast, Russia
- Ivanovo, Moscow Oblast, Russia
The search is for "ivan". Both lines are searched. But here it is necessary that the search first shows those results where the desired substring is closer to the beginning of the string, i.e. I want the results to be as follows:
1) Ivanovo, Moscow region, Russia
2) Sidorovo, Ivanovo region, Russia
I don’t ask for a ready-made solution, but to indicate the direction in which to dig.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexKuznec, 2016-06-26
@AlexKuznec

if there are no built-in methods, I would attach "weight" to the found strings equal to the position of the substring being searched for, and sort by it. I don't know the name of the function, something like substr(...);
[
["Ivanovo, Moscow region, Russia", 1],
["Sidorovo, Ivanovo region, Russia", 11]
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question