Grails 动态搜索,如 google
我正在构建一个 Grails Web 应用程序,并且对 Grails 还很陌生。我正在寻找一个搜索过滤器窗口/窗格,当员工开始在其中输入客户姓名/电话号码或帐号时,会过滤下面窗口中的结果。有点像谷歌实时搜索。然后员工可以从下面的框中选择正确的人。我正在尝试搜索 MySQL 数据。我查看了搜索和过滤窗格插件,他们说它们用于搜索......而不是它们根据在框中键入的内容动态显示。我支持大约 30 台客户端计算机,但它们每天运行大约 3000 到 5000 个查询。主要是通过姓氏或电话进行查找。
实现这种动态搜索结果自动完成的最佳方法是什么?
I am building a Grails web application and am fairly new to grails. I am looking to do a search filter window/pane where as a employee starts to type a customers name/telephone number or account number in it filters the results in the window below. Kinda like google live search. Then the employee can choose the correct person from the box below.. I am trying to search MySQL data. I have looked at the Search and Filter Pane plugins and they say they are for search.. not that they dynamically display based on what is being typed in a box. I am supporting about 30 client computers but they run about 3000 to 5000 queries a day. Mostly look-ups by last name or phone.
What is the best way to implement this kind of auto complete with dynamic search results?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
GrailsUI 插件也具有自动完成功能。不幸的是,该插件不再受支持,但自动完成功能确实有效。并且有详细记录。也许最好使用 jquery,但您可以看看 GrailsUI。
The GrailsUI plugin has autocomplete too. Unfortunately, that plugin isn't supported any more, but the autocomplete does work. And it's well documented. Probably best to go jquery, but you might give GrailsUI a look.
您需要建立一个服务器端点来进行搜索。您需要在客户端构建或集成现有的自动完成小部件。 http://docs.jquery.com/UI/Autocomplete#options。基本上,您将此小部件配置为在满足某些条件后转到 URL(例如用户需要在搜索发生之前输入 2 个字符)
服务端点可以非常简单,但需要快速,因此您可能需要考虑如果您还没有使用二级缓存的话。或者,您可以在不使用缓存的情况下开始,并且仅在性能成为问题时才使用它。
由于您确定了按姓名或电话号码进行搜索,因此您当然需要为每个搜索使用一次 jquery 事物,并且每个都需要一个服务方法(或者一个同时执行这两种操作的服务方法,传入 byName 或 byPhone 的参数,但我只会做单独的服务)。
由于您正在搜索简单的字段,我认为您不需要涉及可搜索插件,但如果您正在搜索包含大量文本的字段,您可能需要使用它。
you need to stand up a server endpoint for search. You need to build or integrate an existing autocomplete widget on the client side. http://docs.jquery.com/UI/Autocomplete#options. Basically, you configure this widget to go to a URL after certain conditions are met (like user needs to enter 2 chars before a search happens)
The service endpoint can be really simple, but it needs to be fast, so you might want to consider using a second level cache if you are not already. Or you can start without the cache, and only use it if performance becomes an issue.
Since you identified search by name or phone number, you will of course need to use the jquery thing once for each, and you need a service method for each (or one service method that does both, passing in a param for byName or byPhone, but i would just do separate services).
Since you are searching on simple fields, I don't think you need to get the searchable plugin involved, but if you were searching thru fields with lots of text, you might want to use it.