Boosting a document on a field value irrelevant to the actual search


For example:
We have documents of a type "contact". A contact can be internal or external.

When searching for contacts, internal contacts should be ranked higher than external contacts.

What would be the best way to implement this?


Take a look at the Function Score Query. With the script_score you have access to the fields in the document and also to the original search score, so it should be possible to boost the internal contacts by a fixed amount.