Drupal 8 – Number of results of incorrect views with the search API

I use Drupal 8 Views in combination with a search index API search. When you use Global: Summary Results in the header or footer of the view, the total number of results displayed in the summary is not the same as the total results of the view. search index.

A similar problem has been reported on Drupal 7, with a solution using hook_views_pre_execute

name === & # 39; MACHINE_NAME_OF_YOUR_VIEW & # 39;) {
$ view-> get_total_rows = TRUE;
}
}
?>

Unfortunately, I can not use this code snippet in Drupal 8 … Maybe a syntax problem?

searchimprove_views_pre_execute function (ViewExecutable $ view) {
if ($ view-> name === & # 39; search & # 39;) {
$ view-> get_total_rows = TRUE;
}}

// searchimprove & # 39; is the name of my module
Search for & # 39; is the machine name of my view.

Thanks in advance!