You point out the real problem and it looks like you correctly understand it.
Following the simple logic, you will see it's simply impossible to search everything that a dynamically generated page can show, no matter what search algorithm does. It's well-known that the results of some code can be even theoretically unpredictable.
In fact, search engines first perform Web scraping and collect data on the scraped site, which is called indexing
No matter how it's done, as some dynamically generated page can generate totally unique content every time it is requested, no indexing can predict relevance of any request to such content.