6

How does Google Suggest work? How does it manage to update the web page on the client so quickly, based on information in a distant Google database? Why does the web page not look ‘jumpy’ if it is being frequently updated?

tshepang
  • 12,111
  • 21
  • 91
  • 136
smallB
  • 16,662
  • 33
  • 107
  • 151

3 Answers3

9

It uses AJAX.

When you are writing your query, it searches for the 10 most requested words matching yours. Then it writes minified JSON on an invisible DIV element. Fast, but still resource intensive.

Try to install Firebug on Firefox or use the Developer Console on Chrome, open the console and start writing "Youtube" or whatever you want. You will see the minified JSON responses.

Good luck :D

Ryan Casas
  • 666
  • 5
  • 19
  • Google Search uses jQuery? I doubt it. – Richard H Jun 25 '11 at 15:44
  • Google uses jQuery in some products for sure, I didn't think search though. And a quick look in Firebug I can't see anything jQuery for Search. – Richard H Jun 26 '11 at 10:04
  • True, but the suggest's GET call is identic to jQueryUI's autocomplete. And the custom HTML tag autocomplete is on the search box too... Don't know now... – Ryan Casas Jun 26 '11 at 12:16
4

In addition to the front-end handling others have talked about, which jQuery is a great example of, you might also be interested in how they approach the idea on the backend. Dr. Peter Norvig has written about how to create a spelling corrector, where similar approaches could be used to find close matches.

Kyle Burton
  • 26,788
  • 9
  • 50
  • 60
1

The whole page is not being updated. Only parts of it are using AJAX - Asynchronous Javascript and XML. Ajax requests can be made in Javascript, and the page updated when the response comes back.

A far more interesting question is how does Google actually search 10bn+ documents in a teeny tiny fraction of a second :)

Richard H
  • 38,037
  • 37
  • 111
  • 138