Laravel 搜索引擎
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28319061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel search engine
提问by user2722667
I am building a REST api using Laravel for a mobile app. And now I need a search engine.
我正在使用 Laravel 为移动应用程序构建 REST api。现在我需要一个搜索引擎。
First off, I have never used any search engine. So I am looking for one thats simple to work with but still good at fulltext searching and filtering "where"
首先,我从未使用过任何搜索引擎。所以我正在寻找一种易于使用但仍然擅长全文搜索和过滤“where”的
The table I want to perform searches on has 1 column (varchar45) that needs to be search by fulltext search, and then there is 5 columns (int) thats used to filter using a "where" statement.- Using the mysql approach. I also perform a inner join on that table in order to print out some other stuff when generating the result.
我要执行搜索的表有 1 列 (varchar45) 需要通过全文搜索进行搜索,然后有 5 列 (int) 用于使用“where”语句进行过滤。 - 使用 mysql 方法。我还在该表上执行内部联接,以便在生成结果时打印出一些其他内容。
So I looked at sphinxand Elasticsearch, and decided to go with ES.
所以我看了sphinx和Elasticsearch,决定用ES。
I have watched the ES intro form Laracon: https://www.youtube.com/watch?v=waTWeJeFp4A
我看过 Laracon 的 ES 介绍:https: //www.youtube.com/watch?v =waTWeJeFp4A
and I also took a look at this package: https://github.com/freekmurze/searchindex
我也看了一下这个包:https: //github.com/freekmurze/searchindex
That left me with a few questions:
这给我留下了几个问题:
1)Do I drop my mysql DB and just store ALLmy data in ES?
1)我是否删除了我的 mysql 数据库并将我的所有数据存储在 ES 中?
2)If 1-yes, can I still use my mysql DB and just use ES to store indexes? - Since I only have to perform a search on one table (search a total of 5 rows).
2)如果是 1-yes,我还可以使用我的 mysql DB 并只使用 ES 来存储索引吗?- 因为我只需要在一个表上执行搜索(总共搜索 5 行)。
3If 2-yes, Do I still keep my current indexes in my mysql table? Eg, fulltext index on title column, FK on another column and index on 3 others.
3如果 2-是,我是否仍将当前索引保留在我的 mysql 表中?例如,标题列的全文索引,另一列的 FK 和其他 3 列的索引。
4Since this is the first time I ever use a search engine, is there any other tutorial/book/snippet out there on how to use ES with Laravel?
4由于这是我第一次使用搜索引擎,是否还有其他关于如何在Laravel 中使用ES 的教程/书籍/片段?
Thanks in advance
提前致谢
回答by Igor Rjabinin
I was solving the same issues recently. My opinions:
我最近正在解决同样的问题。我的意见:
1.no. definitely keep your DB for storing data. ES wasn't built to replace your database. it is (mostly) search engine.
1.没有。一定要保留您的数据库来存储数据。ES 不是为了替换您的数据库而构建的。它(主要)是搜索引擎。
4.you can find nice tutorial here: http://www.fullstackstanley.com/read/simple-search-with-laravel-and-elasticsearch(as a starting point).
I suggest you to read also http://www.elasticsearch.org/guide/en/elasticsearch/guide/(to understand ES better)
4.你可以在这里找到不错的教程:http: //www.fullstackstanley.com/read/simple-search-with-laravel-and-elasticsearch(作为起点)。
我建议你也阅读http://www.elasticsearch.org/guide/en/elasticsearch/guide/(更好地理解 ES)