Quora 中的实时前缀匹配和自动完成
Quora 中如何实现具有前缀匹配的实时自动完成功能?
由于Solr和Sphinx不支持实时更新,那么为了支持实时更新做了哪些改变呢?
How is real time autocomplete with prefix matching implemented in Quora ?
Since Solr and Sphinx doesn't support real-time updating so what changes were made to support real time updating?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来它是使用 javascript 和 jquery 完成的。我从 Quora 主页上的缩小脚本中抓取了几行关键行,我认为这些行支持了这一理论:
这是对提供 JSON 数据的资源的 ajax 调用:
请注意,成功的结果被放入“a”变量中。然后,稍后这是基于“question_box”元素的按键的自动完成,该元素是从“a”的父元素完成的,
我认为这是无可争议的,但有未缩小的脚本进行比较仍然很好。例如,我看不到 resultsQueryPath 来自哪里(我无法找到它的来源,可能是故意混淆的)。
Looks like it's done using javascript and jquery. I grabbed a few key lines from the minified script on the Quora homepage that I think support this theory:
Here's an ajax call to a resource providing JSON data:
note that the successful result gets put into the "a" variable. Then later here's the autocompletion based on the keydown of the "question_box" element which is completing from the parent of "a"
I think this is pretty incontrovertible, but it would still be nice to have the un-minified script to compare. For instance I can't see where resultsQueryPath comes from (I can't locate it's source, may be intentionally obfuscated).