简体   繁体   English

优雅的搜索方式(PHP + MySQL)

[英]Elegant way to search (PHP + MySQL)

We have a website written in Codeigniter framework. 我们有一个用Codeigniter框架编写的网站。 Now we want to have a nice and fast soundex based search function to the site. 现在我们想要为网站提供一个漂亮而快速的基于soundex的搜索功能。 It's just a micro blog so we would only search in the titles of the posts. 它只是一个微博客,所以我们只搜索帖子的标题。

So what would be the best for us? 那对我们来说最好的是什么?

I have two ideas: 我有两个想法:

  1. Create another column in the post table with the soundex copy of the title and simply have FULL-TEXT index on it. 使用标题的soundex副本在post表中创建另一列,并在其上只有FULL-TEXT索引。

  2. Explode the words from the titles and save the soundex equivalent of the words in a new table with the id of the post. 从标题中分解单词,并在新表中保存与单词相对应的soundex,其中包含帖子的id。 Just like an automatic tag system. 就像一个自动标签系统。

Which method is the better and why? 哪种方法更好,为什么? Can you suggest a better way? 你能建议一个更好的方法吗?

Thanks for all the answers! 感谢所有的答案!

Soundex is great - but it usually doesn't meet user expectations for search (established by Google etc.). Soundex很棒 - 但它通常不符合用户对搜索的期望 (由Google等建立)。

The common solution to text searching, including fuzzy searches and stemming, is to use something like SOLR ; 文本搜索的常见解决方案,包括模糊搜索和词干,是使用类似SOLR的东西; it's relatively easy to integrate with PHP using web service calls. 使用Web服务调用与PHP集成相对容易。

The Zend framework has Lucene integration (never used it, but it might save you some time) - Lucene is an open source free text search platform . Zend框架具有Lucene集成 (从未使用它,但它可能会为您节省一些时间) - Lucene是一个开源免费文本搜索平台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM