Backport PR #37432 on branch 1.1.x
(cherry picked from commit 52925335fe6d5f1ea6c79bb03da70654d9be9668)

Tried to merge it. Hopefully nothing was broken in the process. Run the indexing tests locally, but have to wait for ci

cc @simonjayhawkins 
Thanks @phofl 