I have documents that include the fields 'description' and 'supplier'. Description is a bunch of text and supplier is a short text code such as ABC. Users pass in a query string that searches the description field, and I want the results to be sorted by supplier, _score. Not a problem so far.
However the users can also pass in one or more supplier codes. These values are not intended to filter out the results, rather they are intended to alter the way the sort works. Any documents with matching supplier codes should be displayed first.
So if the user includes a supplier code of CCC then the results should look something like this:
'Doc1 description', 'CCC'
'Doc2 description', 'CCC'
'Doc3 description', 'AAA'
'Doc4 description', 'AAA'
'Doc5 description', 'BBB'
Is there a way to achieve this in a single query, or will I need to do two queries and stitch them together? I need to support pagination so a single query solution would be much easier if it's possible. I suppose I could write a scoring script to manipulate the score that is given to each document but would that be the best approach?