Search term position

Hi, I'm using version 6.8.

How to configure the search to prioritize products that have the search term in ascending order? For example, when typing the word "oil" (cooking oil) I want the search result to prioritize products that have the first word searched. What is happening is that the result returns products without order that have the search term at the beginning, in the middle and at the end, attached.

This my index settings:

    {
       "number_of_shards": 1,
       "number_of_replicas": 0,
       "analysis": {
           "analyzer": {
               "std": {
                   "tokenizer": "standard",
                   "char_filter": "html_strip",
                   "filter": ["standard", "elision", "asciifolding", "lowercase", "length"]
               },
               "keyword": {
                   "tokenizer": "keyword",
                   "filter": ["asciifolding", "lowercase", "length"]
               },
               "keyword_prefix": {
                   "tokenizer": "keyword",
                   "filter": ["asciifolding", "lowercase", "edge_ngram_front"]
               },
               "text_prefix": {
                   "tokenizer": "standard",
                   "char_filter": "html_strip",
                   "filter": ["standard", "elision", "asciifolding", "lowercase", "edge_ngram_front"]
               },
               "text_suffix": {
                   "tokenizer": "standard",
                   "char_filter": "html_strip",
                   "filter": ["standard", "elision", "asciifolding", "lowercase", "edge_ngram_back"]
               }
           },
           "filter": {
               "edge_ngram_front": {
                   "type": "edgeNGram",
                   "min_gram": 1,
                   "max_gram": 20,
                   "side": "front"
               },
               "edge_ngram_back": {
                   "type": "edgeNGram",
                   "min_gram": 1,
                   "max_gram": 20,
                   "side": "back"
               },
               "length": {
                   "type": "length",
                   "min": 1,
                   "min_subword_size": 1
               }
           }
       }
    }

I think you can do that using a bool query with multiple queries within the should array.
Then you can boost for example a prefix query.

Hi @dadoonet How i do it on index settings?

You can't I think.

Thanks for listening, but I didn't understand how I should solve this problem.

Is there something I should be more specific about?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

Okay, I have the magento e-commerce application, which has the search module from Wyomind Elasticsearch® Autocomplete. Within this module there is an index settings configuration (the json file from the first post) where I was recommended by the module's support to solve my problem.

The scenario is as follows, when I search for a product by the term "oil", the search results are products with the name "Mobil Oil", "Soy Oil", "Oil Shampoo", "Oil Sardine", "Sunflower Oil ", "Lavender Oil Adhesive Gel " and the expected result should be "Oil Shampoo", "Oil Sardine", "Lavender Oil Adhesive Gel ", "Mobil Oil", "Soy Oil", "Sunflower Oil ", that is, in ascending order from the searched term.

Do you have any way to configure the query which is ran behind the scene?
If not, could you at least share the query which is generated by the plugin?

Cc @Aurelien_FOUCRET in case he has an idea.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.