laravel scout_使用Laravel Scout和Algolia实现地理搜索
laravel scout
Laravel Scout makes it very easy to setup an external search engine to create consumer-grade search quickly. The package comes with Algolia as a default search engine. I'd like to demonstrate how to make use of the geo-location search feature with Scout.
Laravel Scout使设置外部搜索引擎非常容易,以快速创建消费者级搜索。 该软件包随附Algolia作为默认搜索引擎。 我想演示如何在Scout中利用地理位置搜索功能。
In this tutorial, you'll learn how to prepare your data for Algolia and Laravel Scout to retrieve items based on location.
在本教程中,您将学习如何为Algolia和Laravel Scout准备数据以根据位置检索项目。
We recommend you use front-end search for your app because this implementation model is most efficient. That being said, there are cases where you need backend search, for instance, if you want to generate reports.
我们建议您对应用程序使用前端搜索 ,因为这种实施模型效率高。 话虽如此,在某些情况下,例如,如果您想生成报告,则需要进行后端搜索。
入门 ( Getting Started )
For this tutorial, I quickly set up a Laravel app with dummy data of airports around the world. You can find the project on GitHub. You can install it by following the notes in the readme.
对于本教程,我快速设置了一个Laravel应用程序,其中包含世界各地机场的虚拟数据。 您可以在GitHub上找到该项目 。 您可以按照自述文件中的说明进行安装。
If your use case is different or your data isn’t organised this way, feel free to post to our community forum.
如果您的用例不同或您的数据不是按照这种方式组织的,请随时发布到我们的社区论坛 。
步骤1:安装侦察员 ( Step 1: Install Scout )
Scout comes as a separate package, we'll use composer to pull it into our project.
Scout作为一个单独的软件包提供,我们将使用composer将其拉入我们的项目。
The whole point of Scout is to add an abstraction layer so your code will be the same for any search engine you choose. Since we're using Algolia, this will require our PHP client.
Scout的重点是添加一个抽象层,因此您选择的任何搜索引擎的代码都将相同。 由于我们使用的是Algolia,因此这需要我们PHP客户端。
-
相关文章