Infographic by PPC Blog
Google is pretty secretive about all this—understandably, as it's the company's bread and butter and there are viable alternatives out there, like Microsoft Bing and Yahoo—so this infographic is based on the little information and clues Google has given. Even for someone who deals with SEO (search engine optimization) all day (alternate headline for this post: "Google Apple Babies Steve Jobs Boobs iPhone Obama Scandal!"), there's some stuff in here I didn't know.
For example, it's totally reasonable, but I didn't realize that Google would have to find synonyms to every keyword a user searches. Also, there are way more legal considerations than anyone would expect, likely lots more than are listed here, and that's all policed through several different means including user ratings, notifications from content-owning agencies and government groups, spam reports, and its own Search Quality Team.
Google search really is amazing, and it's even more amazing that this entire flowchart (which is just a basic overlook) all happens in milliseconds.