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)
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
I think the completion suggester may be a better fit for what you're trying to do. It will only offer suggestions that start with the prefix you're requesting. It also allows you to specify a weight for every suggestion, which will be used for ranking the suggestions. In your case the weight could be equal to the number of occurrences.
If you now send the following suggest request to Elasticsearch, it will only return documents 1 and 2, and it will rank them based on the provided weight:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.