First, walk the whole web
Before any searching happens, programs called crawlers travel the web endlessly, following links from page to page and copying what they find. The web has hundreds of billions of pages, so crawling never finishes; it just keeps refreshing, like painting a bridge that grows.
Each copied page is taken apart and filed into an index: a vast lookup table recording which words appear on which pages, where, and in what company. Building the index is the real work — answering your question afterwards is the quick part.
Answering in a blink
When you type a query, the engine consults its index, not the live web. It gathers candidate pages, then ranks them using hundreds of signals: how well the words match, whether the page is trusted and well-made, how fresh it is, where you are, and what people asking similar questions found useful.
Early engines leaned heavily on one famous signal — the number and quality of links pointing to a page, treating each link as a vote. Modern ranking mixes far more, and the details are guarded, partly to stay ahead of people trying to game them.
A librarian for a library with no walls
Think of the engine as a librarian who has read everything, keeps perfect notes, and answers in a quarter of a second. The librarian cannot show you books that were never delivered — pages no crawler could reach simply do not exist for search.
Knowing this makes you a sharper searcher: choose words the page itself would use, and remember that the first answer is a ranking, not a verdict.

