title: How does Google perform search (for any given query) so quickly (over so many documents) and still manage to customize the results?
body: <p>How does Google perform search so quickly?</p>
  
  <p>After spending some time thinking about search I've realized how complicated it is. </p>
  
  <p><strong>On the query side:</strong>
  If the number of queries people type is limited (e.g. 1-2 words), the results could be precomputed for all websites and then looked up.</p>
  
  <p>This could work well if queries are 1-2 words long. The number of words in real queries can be large though and therefore the number of unique queries is almost infinite. This means that whilst some queries may be precomputed, the rest are almost certainly not. It's interesting to note that Google doesn't take a significantly longer time to return a longer query than a shorter one.</p>
  
  <p><strong>On the document side:</strong> From my understanding Google constructs features from each document (such as word frequency, links, etc) and runs it through an algorithm (most likely a machine learning algorithm?). </p>
  
  <p>Is it correct to assume that some features are the same for all queries (such as the number of links to highly ranked websites) whilst other features are more specific to the query (e.g. how many times the query words appear in the document)?</p>
  
  <p>Given the above, does this mean that each query must generate features for every document in Google's index? If not how does Google narrow this down? How does so much computation happen so quickly? Is a significant portion of Google's infrastructure used for each query to compute these features and predict the relevance in parallel, or do they approach it in another way?</p>
  
  <p>Please note that whilst only the top 10-20 of the links for results may be clicked, Google still has to understand which 10-20 documents from their whole library they are - which means that all the documents need to be evaluated to some degree.</p>
  
  <p><strong>On the user side:</strong> Further to the above, Google customize the results based on your previous search history/habits. Does this mean that documents have features based on each user individually as well (for example the number of similar documents you've looked at in the past)? Or does Google use clustering methods to cluster their users and have document features for users most similar to you (e.g. 90% of users who visited the sites you have visited have clicked on this link to this document)? </p>
  
  <p>If it's none of the above then how do they achieve customization of search results for so many documents on the web? And how do they do it in a fraction of a second?</p>