B树适合自动建议/自动完成Web表单吗? [英] Does a B Tree work well for auto suggest/auto complete web forms?

查看:52
本文介绍了B树适合自动建议/自动完成Web表单吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自动建议/完成字段在整个网络上使用.谷歌似乎已经掌握了它,因为只要搜索查询中的一种类型,建议就几乎立即返回.

Auto suggest/complete fields are used all over the web. Google has appeared to master it given that as soon as one types in a search query, suggestions are returned almost instantaneously.

我假设用于实现此目的的框架涉及Web层上的快速内存数据存储.我们正在基于零售产品构建Grails应用程序,因此用户可以搜索 Can ,其中应该建议诸如 Canon Cancun 之类的内容,并想知道缓存在内存中的Java B树是否足以满足通过AJAX作为JSON返回的快速自动完成的需求.在jQuery AutoComplete字段之外,是否存在任何框架和/或库来促进此解决方案的开发?

I'm assuming the framework for achieving this involves a fast, in-memory data store on the web tier. We're building a Grails app based around retail products, so a user may search for Can which should suggest things like Canon, Cancun, etc, and wondering if a Java B-tree cached in memory would suffice for quick auto completes returned as JSON over AJAX. Outside of the jQuery AutoComplete field, do any frameworks and/or libraries exist to facilitate the development of this solution?

推荐答案

自动完成是文本匹配的信息检索问题.您可以执行自己的B树并编写自己的逻辑以将单词与其他单词匹配.但是随后,您必须实施 Porter Stemming ,即

Autocomplete is a text matching, information retrieval problem. Implementing your own B-tree and writing your own logic to match words to other words is something you could do. But then you would have to implement Porter Stemming, a Vector Space Model, and a String-edit distance calculation.

...或者您可以使用 Lucene 及其派生词,已经做了很多这样的事情.如果您真的很在意用于存储这些内容的数据结构,则可以深入了解其来源.但是我高度怀疑自己编写并自己做所有事情从长远来看会更易于维护和高效.

...or you could use Lucene and its derivatives, which do a lot of this stuff already. If you really care about the data structures used to store this stuff, you could dive into its source. But I highly doubt writing your own and doing it all yourself would be more maintainable and efficient in the long run.

对此最流行的Grails生态系统插件之一是 Searchable ,该方法在Ledbrook& amp;中提到;史密斯的 Grails in Action .它在幕后使用了Lucene,使您可以轻松地将全文搜索添加到您的域类中.(例如,查看GinA的第8章或可搜索的文档.)

One of the more popular Grails ecosystem plugins for this is Searchable, which was mentioned in Ledbrook & Smith's Grails in Action. It uses Lucene under the covers, and make sit pretty easy to add full-text search to your domain classes. (For example, check out chapter 8 in GinA or the searchable docs).

这篇关于B树适合自动建议/自动完成Web表单吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆