Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Google predict our words? [duplicate]

Possible Duplicate:
How does Google Instant work?

Often we use Google to search any content, but when we type any word in the text box of Google's engine, Google tries to predict the word or even recently it uses Google Instant Search to produce the result on the fly. How does this work?

That is without even the user have pressed the search button, how does server send the result immediately? Because as a user we haven't requested for the result, but still server produce a result, how has this been implemented?

like image 708
Ant's Avatar asked Nov 14 '22 01:11

Ant's


1 Answers

Essentially, there are JavaScript key event listeners on the search box. When these detect keyboard input, an Ajax request is made to Google's server.
The Ajax request will include the currently entered text, which will likely be compared to popular search terms. A list of possible completions is sent back using JSON, and inserted back into the page using JavaScript.

As for Google Instant Search, instead of returning a list of possible completions, a list of results for the most likely search term you entered will be returned and JavaScript used to update the page.

To learn more about this stuff, it's worth learning about JavaScript, Ajax and DOM manipulation. JavaScript libraries such as jQuery or Prototype can make this stuff much easier.

like image 138
Magnus Avatar answered Jan 14 '23 12:01

Magnus