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.