开发者

How does Google predict our words? [duplicate]

开发者_StackOverflow中文版This question already has answers here: Closed 11 years ago.

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?


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.


Google uses javascript to send your text as you type it to the server and start showing the results.


For the Instant Search result Google will probably just listen for a key press event and if so send a request for the results and then display them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜