Well, that’s because you can’t. For whatever reason.

I can’t modify the variables in search-result.html.twig like so:

function mytheme_preprocess_search_result(&$variables) {
$variables[‘result’][‘testvar’] = ‘beeeg test!’;
$variables[‘result’][‘title’] = ‘AMAAAAZING NEW TITLE!!!’;
}

Hmm. Okay.

But I can access testvar like so in the twig file:

{{ result.testvar }}

And if I really want to change the title of my search results, I can do this:

function mytheme_preprocess_item_list(&$vars) {
foreach ($vars[‘items’] as &$item) {
$res =& $item[‘value’][‘#result’];
$res[‘title’] = ‘bleaaargh!’ ;
}
}

And now all titles are set to ‘bleaaargh!’ as they should be.