ActionView::Template::Error when paginating many global search results
Summary
Enabling the Advance Global search ( https://docs.gitlab.com/ee/user/search/advanced_global_search.html ) and searching for a common word produces many results causing a 500 error when paginating.
What is the current bug behavior?
After enabling the global search and indexing all the projects, if our search query produces more than 10000 results, with 20 results per page, and the user tries to see page 501 or higher, it will show a 500 error. This is the corresponding exception we are retrieving from our Sentry instance:
ActionView::Template::Error: [500] {"error":{"root_cause":[{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [2101040]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"gitlab-production","node":"XLoQJl7-RyO5zrghu57sLw","reason":{"type":"query_phase_execution_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [2101040]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."}}]},"status":500}