谷歌建议,它是如何工作的?
Google 建议如何运作?它是如何根据远程 Google 数据库中的信息如此快速地更新客户端网页的?为什么经常更新的网页看起来并不“跳跃”?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它使用 AJAX。
当您编写查询时,它会搜索与您的查询最匹配的 10 个单词。然后它在不可见的 DIV 元素上写入缩小的 JSON。速度快,但仍然占用资源。
尝试在 Firefox 上安装 Firebug 或使用 Chrome 上的开发者控制台,打开控制台并开始编写“Youtube”或任何您想要的内容。您将看到缩小的 JSON 响应。
祝你好运:D
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
除了其他人讨论过的前端处理(jQuery 就是一个很好的例子)之外,您可能还对他们如何在后端处理这个想法感兴趣。 Peter Norvig 博士撰写了有关如何创建拼写校正器的文章,其中可以使用类似的方法找到相近的匹配项。
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.
整个页面没有更新。只有部分内容使用
AJAX
- 异步 Javascript 和 XML。 Ajax 请求可以用 Javascript 发出,响应返回时页面会更新。一个更有趣的问题是 Google 如何在短短一秒内搜索超过 100 亿份文档:)
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 :)