ElasticSearch completion suggester without respecting terms order when typing

I wanna make an autocomplete feature to search by full name(first name(s)+ last name) using Elastic Search completion suggester.
when tapping, user can start with any term composing the full name.
for example to look for OUNZAIN Allel Ali, the end user could tape(order is not important ):
ounzain allel ali, ounzain ali allel, allel ali ounzain ali allel ounzain

after reading some about completion suggester and analyzer , as a first solution I have created an index with default
parameters (ie: simple analyzer) and a completion field, as described bellow

{
    "settings" : {
        "number_of_shards" : 5
    },
    "mappings" : {
        "_doc" : {
            "properties" : {
                "suggest_member" : { "type" : "completion"
                
                }
//... there is other fields in my index of course
         }
        }
    }
}

and when indexing, I have filled in the completion field with an input parameter which is
supposed(according to my comprehension) resolve the probleme of not respecting order.
I'll explain my solution using the above exemple: for the name: OUNZAIN Allel Ali
the script for indexing is:

 {
"properties" : {
                "suggest_member" :{
				"input":["ouzain allel ali","ouzain ali allel", " ali ouzain allel"," ali allel ouzain",
"allel ouzain ali","allel ali ouzain"]				]
				}
}

the solution is to fill in the input parameters with all the possibile combinations of the couple first name(s)/last name.

I need a professional opinion about this solution, is it a good one? is there another way to implement my feature?

Many thanks for considering my request. :slight_smile:

this solution requires a fair share of work on your side to provide the data. If that is feasible and works out, nice. However you might also want to take a look at the new search-as-you-type datatype, allowing you to just store the name as is.

Hope this helps.

@spinscale, thank you for your answer, :slight_smile:
yes, i have already implemented this solution and it works. but I'd like to know if it's a correct one, if it will not create duplicate data when ES will create a inverse index when creating document, because in the input field I have repreted terms many times?
I'll also take a look to search as you type field.

the completion suggester stores its data in another data structure than the inverted index, that is also loaded into the heap permanently, so there will be differences in its runtime requirements.

1 Like

@spinscale, here is a screenshot of my autocomplete feature

no matter the order of terms the engine retreive the same element (document)

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