O
O
Oleg-Ukraine2017-11-27 19:31:05
elasticsearch
Oleg-Ukraine, 2017-11-27 19:31:05

How to properly map or write a query?

I have products with names consisting of 1-5 words. You need to search by product name.
Example. There are products with names.
Brown slippers
Green slippers
Green stealths
Green tanks
When user enters “tapo”
must be given away
Brown slippers
Green slippers
when typing “green”
Green slippers
Green stealths
Green tanks
All this currently works when mapping the title field: {type: text, boost: 5 }
and request

{"query":{
  "bool":{
    "must":[{
      "prefix":{"title":{"value":"зел"}
      }
    }]
  }}
}

The problems start when the user enters “green ta”
I would like the result to be
green slippers
green tanks
but unfortunately the result is returned empty. I would be very grateful if you tell me something on the mapping or request to solve this problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2017-11-28
@Oleg-Ukraine

Break terms into ngram https://www.elastic.co/guide/en/elasticsearch/guid...

O
Oleg-Ukraine, 2017-11-29
@Oleg-Ukraine

Another point, the current request is solved by a rather simple match_phrase_prefix operator

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question