The journey of a query starts before you ever type a search, with crawling and indexing the web of trillions of documents.
How search works is a series of processes as explained here by a Google expert help lay the foundation — Of How Search Works . Google gathers and organizes information on the web so Google Search can return the most useful results to searchers. Google’s index is well over 100,000,000 gigabytes, and they’ve spent over one million computing hours building it. Learn more about the basics of how search works in this short video.