如何在Laravel中允许较长的自动完成搜索列表 [英] How to allow long autocomplete search list in laravel

查看:93
本文介绍了如何在Laravel中允许较长的自动完成搜索列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel 5创建一个酒店预订系统,该系统将与第三方API集成在一起,以搜索世界各地的酒店.

I'm using Laravel 5 to create a hotel booking system, which will integrate with third-party API for searching hotels all over the world.

在搜索表单中,有一个位置字段,用户可以在其中输入要访问的城市,然后根据输入的文本显示自动完成下拉列表.

In search form, there is a location field, where user can type city which they want to visit, and a autocomplete dropdown will show according to entered text.

我面临的问题是:来自世界各地的城市太多了.该列表超过1万个城市.由于此字段,网页一直处于加载状态,并且没有响应.

The problem I'm facing is: there are too many cities from all over the world. The list is more than 10 thousand cities. The webpage keeps loading and unresponsive due to this field.

如何将Expedia显示的所有城市都放入自动填充列表中?

How can I put in all the cities in autocomplete list like what Expedia is showing?

谢谢.

推荐答案

此类网站(可能)使用 ElisticSearch之类的技术 SOLR . 但是,Laravel还可以使用像Algolia这样的第三方服务.但是前两个可以安装在自己的服务器上.阿尔戈利亚是有偿的. https://laravel.com/docs/5.7/scout

Websites like these (probably) use techniques like ElisticSearch or SOLR. However Laravel also makes it possible to use a third party service like Algolia. However the first 2 you can install on your own server. Algolia is payd for. https://laravel.com/docs/5.7/scout

因此,我建议您使用Laravel Scout,因为您的问题被标记为Laravel.但是,一段时间后,推荐的外部服务非常昂贵.我个人会推荐Elasticsearch.显然,甚至有一个软件包可以使您的应用程序与Elasticseach服务之间的连接更容易: https://github.com/babenkoivan/scout-elasticsearch-driver

So I would suggest using Laravel Scout as your question is tagged Laravel. However the recommended external service is quite expensive after some time. Personally I would recommend Elasticsearch. There apparantly is even a package to make the connection between your app and the Elasticseach service easier: https://github.com/babenkoivan/scout-elasticsearch-driver

http://okfnlabs.org/blog/2013 /07/01/elasticsearch-query-tutorial.html

这篇关于如何在Laravel中允许较长的自动完成搜索列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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