Hi there,
I'm trying to use 'search_as_you_type' for auto complete. I got the idea of how this works, but stuck with a basic scneario.
for exmaple I have a field with type 'search_as_you_type'
{
"mappings": {
"properties": {
"my_field": {
"type": "search_as_you_type"
}
}
}
}
and the docs are like:
{"my_field":"apple dog bob and light"}
{"my_field":"apple doll charlie "}
{"my_field":"apple doll cat"}
{"my_field":"apple donut who does not like"}
when search with "apple d", I will get all these docs returned, which is good as design.
But as auto completion, I may only want "dog", "doll" and "donut" as completion of "d".
For this case, if the result number is set to 3, then "donut" will lose.
I tries to aggregate on 'my_field._2gram' to get at least "apple dog","apple doll" and "apple donut", but seems I can not do it.
Is there any solution for such case?
Thanks.