Sorting Context Suggester

Hi everyone! First I'll explain what my setup is and what the result I'm looking for is.

I'm looking to use the following functionality in an autocomplete manner.
The records in my index have a contentType. I need to group the results by contentType, then sort every group by different criteria(constructing a sortValue using different fields from every record). And finaly receive only the top result in every contentType.

For example, I'll send at query time my prefered contentTypes, for instance: Doctor, Expert, Hospital, MedicalEvent. And I want to receive the Doctor with the most profileViews, the Expert with the longest expertise list, the Hospital with the most likes and the MedicalEvent with the most participants.

I managed to get this functionality using FunctionScore to attach weights to the contentTypes and the TopHits Aggregation with script_sort to create a different sortValue for every contentType, but obviously I need to use the completion suggester. So using the context suggester I managed to attach respective weights to every context(ContentType), but how do I sort the results from every context? Is this even possible? I wonder if I can use the FunctionScore and TopHits Agg and how slow it would be?

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