A very useful hook
relevanssi_hits_filter, which lets you modify the hits directly. The filter passes an array, where index 0 gives the list of hits in the form of an array of post objects and index 1 has the search query as a string, in case you need that information for something.
The filter is very nice, if you want to adjust the search results some how. You can add posts to the results, make sure some posts float on top, remove certain posts… The WPML support Relevanssi has, for example, is based on this filter: results that are not in the correct language are filtered away at this point.
The filter expects you to return an array containing the array of post objects in index 0. The search query is just for information, but if there are many filters on the
relevanssi_hits_filter hook, some later function may expect it to be there. So, in order to avoid problems, it’s best to include the query string in the returned array, like this (assuming the function parameter array is called $hits):
$hits = $your_processed_hits_array; return $hits;
For more information, see more examples in user manual.