谷歌如何预测我们的言语?
可能的重复:
Google 即搜即得的工作原理是什么?
我们经常使用 Google 来搜索任何内容,但是当我们在 Google 引擎的文本框中输入任何单词,Google 会尝试预测该单词,甚至最近它使用 Google 即时搜索即时生成结果。这是如何运作的?
也就是说,即使用户没有按下搜索按钮,服务器如何立即发送结果?因为作为用户,我们没有请求结果,但服务器仍然产生结果,这是如何实现的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
本质上,搜索框上有 JavaScript 按键事件监听器。当它们检测到键盘输入时,就会向 Google 服务器发出 Ajax 请求。
Ajax 请求将包括当前输入的文本,该文本可能会与流行的搜索词进行比较。使用 JSON 发送回可能的完成列表,并使用 JavaScript 插入回页面。
对于 Google 即时搜索,不会返回可能完成的列表,而是返回您输入的最可能的搜索词的结果列表,并使用 JavaScript 更新页面。
要了解有关此内容的更多信息,值得学习 JavaScript、Ajax 和 DOM 操作。 JavaScript 库,例如 jQuery 或 原型可以使这件事变得更容易。
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 使用 JavaScript 将文本发送到服务器并开始显示结果。
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.