Drupal 8 – The result of the views is incorrect with the search API

I am using Drupal 8 Views in combination with a Search API search index. When using Global: Summary of 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 Search index.

A similar problem has been reported in 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 snippet of code in Drupal 8 … Maybe a syntax problem?

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

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

Thanks in advance!