My goal is to create a search engine (elasticsearch 7.x) that suggests you the correct searches to input, a sort of what amazon does, based on previous searches (machine learning). My fields to index are the following:
- Keywords = search phrases
- occurrences = number of times this search was performed
- total = number of results (it only to exclude searches that produced no results)
INDEX
{
"mappings": {
"properties": {
"keywords": {
"type": "search_as_you_type"
},
"occurences":{
"type": "integer"
}
}
}
}
What I would like to achieve is a search as you type "starts with" but when I apply the query:
{
"query": {
"match_phrase_prefix": {
"keywords": "fill"
}
}
}
I get not only keywords starting wiht fill (such as "filler") But also other that contain the query, such as "real filler" or any other phrase that contains "fill". What I would like to ahcieve is returning only the phrases starting with the query term.
The next step would be to boost results that have a higher value of occurences
Any hint?
Thank you