Returning Search Results
After Google's spiders crawl the web, they build an index of all the retrieved information. (In the past, updating the index happened once every few months, but now Google crawls the web and updates the index continuously). Rather than search every document when a query is made, Google has a great number of computers that hold lists of pages containing a given word.The example Google provides is that if someone searches for civil war, they can return every result that appears on both the list for civil and the list for war.
Although Google may tell you that they have millions and millions of results for your search, they never actually create the full list; instead, they just retrieve the most relevant results. Google uses over a hundred factors to rank each page and tries to return pages that are both relevant and reputable, which is why highly trusted sites like CNN and Wikipedia often who up at the top of the search results, but brand new sites can show up there as well if they have highly targeted information.