High search latency after upgrading from es 6.8 to 7.12.1

We had a similar issue after upgrading to 7.12 and we also noticed CPU usage on most our elasticsearch nodes was very high after the upgrade. I found an issue in github that looked promising and it did, in fact, solve our problem. It has to do with searches in non-default Kibana spaces not being deleted properly. There is a workaround given in the github issue page.

https://github.com/elastic/kibana/issues/96124