PHP 和 MYSQL 的最佳搜索算法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4912345/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:15:16  来源:igfitidea点击:

What is the best search Algorithm for PHP & MYSQL?

phpmysqlsearch

提问by WEBProject

I want to make a search for articles on my website - is it ok to use just plain 'LIKE' statement or is there a better search algorithm to use with MySQL? (its important it be efficient)

我想在我的网站上搜索文章 - 可以只使用简单的“LIKE”语句还是有更好的搜索算法与 MySQL 一起使用?(重要的是要高效)

采纳答案by chustar

You should look into using Full-Text Search.
It might also help you to read about the Tradeoffs of MySQL LIKE vs Full-Text

您应该考虑使用Full-Text Search
它也可能帮助您阅读MySQL LIKE 与 Full-Text权衡

回答by Alfred

is it ok to use just plain 'LIKE' statement or is there a better search algorithm to use with MySQL? (its important it be efficient)

可以只使用简单的“LIKE”语句,还是有更好的搜索算法与 MySQL 一起使用?(重要的是要高效)

Like

喜欢

If it is important to be efficient then I think LIKE is absolutely not the way to go.

如果效率很重要,那么我认为LIKE 绝对不是要走的路

Full Text Search: 392 Sec Full Text Search (Cached): 272 Sec

Full Text Boolean Mode 12 Sec Full Text Boolean (Cached) 11 Sec

Mnogosearch (external) 3.5 Sec Mnogosearch (external cached) 1.06 Sec

Sphinx 0.23 Sec Sphinx Cached 0.15 Sec

LIKE %...% 30sec Sec LIKE %...% (Cached) 29sec Sec

全文搜索:392 秒全文搜索(缓存):272 秒

全文布尔模式 12 秒全文布尔(缓存)11 秒

Mnogosearch(外部​​)3.5 秒 Mnogosearch(外部​​缓存)1.06 秒

狮身人面像 0.23 秒狮身人面像缓存 0.15 秒

LIKE %...% 30sec Sec LIKE %...% (Cached) 29sec Sec

Sphinx

狮身人面像

Probably Sphinxis the most efficient method, which also has support for MySQL. To be honest I have never used Sphinxmyself, but some very big sites use it.

Sphinx可能是最有效的方法,它也支持 MySQL。老实说,我自己从未使用过Sphinx,但一些非常大的网站使用它。

enter image description here

在此处输入图片说明

It is probably more difficult to setup then another(probably last) alternative.

设置另一个(可能是最后一个)替代方案可能更困难。

MySQL full-text search

MySQL全文搜索

I also think MySQL full-text-searchwould probably be fast enough and a easier to use.

我还认为MySQL 全文搜索可能足够快并且更易于使用。

回答by Nuno

I would consider Using Apache Solr https://lucene.apache.org/solr/or Elastic Search http://www.elasticsearch.org/

我会考虑使用 Apache Solr https://lucene.apache.org/solr/或 Elastic Search http://www.elasticsearch.org/