简体   繁体   English

基于PHP的搜索框架

[英]PHP-based search frameworks

I'm going to make a small site which requires advanced search capabilities. 我打算建立一个需要高级搜索功能的小网站。 Since reinventing the wheel isn't such a worthwhile activity, I've done a little googling and found there are some PHP based search frameworks, one of which is integrated into Zend framework. 由于重新发明轮子不是一个值得的活动,我做了一些谷歌搜索,发现有一些基于PHP的搜索框架,其中一个集成到Zend框架。

What I would like to have in the framework: 我想在框架中拥有什么:

  1. Both full-text and catalogue search capabilities 全文和目录搜索功能
  2. Display results sorted by relevance 显示按相关性排序的结果
  3. Ability to filter results by category 能够按类别过滤结果
  4. Sorting results by various criteria 按各种标准对结果进行排序
  5. Fast search 快速搜索
  6. Fast insertion not required 不需要快速插入

Since the site will feature pretty much static content (some text and a product catalogue), I might go with some pre-generated index. 由于该网站将具有相当多的静态内容(一些文本和产品目录),我可能会使用一些预先生成的索引。

Are there any (free) frameworks that could meet the above requirements? 是否有任何(免费)框架可以满足上述要求? Suggestions, tips and ideas are more than welcome. 建议,提示和想法非常受欢迎。 It'd be great if you could share your experiences implementing a search system. 如果您可以分享实施搜索系统的经验,那就太棒了。

You may want to go with a CMS such as Joomla or Drupal if the site will have static content only. 如果该站点仅具有静态内容,您可能希望使用诸如JoomlaDrupal之类的CMS。 Both have good search systems. 两者都有很好的搜索系统。 However, search really depends on what sort of content you have. 但是,搜索实际上取决于您拥有的内容类型。 If its simply searching the HTML of the page, that's one thing, but searching the database for a particular model # of a product is another, in which case you need a shopping cart/e-commerce system rather than a CMS. 如果它只是搜索页面的HTML,这是一回事,但在数据库中搜索特定型号的产品#是另一种,在这种情况下,您需要购物车/电子商务系统而不是CMS。

Have a look at Omega (based on Xapian) - a link to the Xapian project page 看看Omega (基于Xapian) - Xapian项目页面的链接

You can integrate it cgi-wise. 你可以用cgi-wise集成它。 Because it's based on the blindingly fast Xapian it will be one of the fastest options if you set it up correctly. 因为它基于快速的Xapian,如果你正确设置它将是最快的选项之一。 It can do everything you ask for (including relevance for search results, index web server documents (html, pdf, word, excel, sql databases...) do 'stemming' etc...) 它可以做你要求的一切(包括搜索结果的相关性,索引web服务器文档(html,pdf,word,excel,sql数据库......)做'阻止'等...)

Another (also very good option) would off course be Apache Lucene --> it's this one that is included in the Zend framework you referenced ("Zend Search"). 另一个(也是非常好的选择)当然是Apache Lucene - >这是你引用的Zend框架中包含的这个(“Zend Search”)。 It can do all the same tricks, although i personally prefer Xapian. 它可以做所有相同的技巧,虽然我个人更喜欢Xapian。

Edit: be aware that Omega (and Xapian) are GPL whereas Apache Lucene is LGPL if i recall correctly. 编辑:请注意,Omega(和Xapian)是GPL,而Apache Lucene是LGPL,如果我没记错的话。

definitely use SOLR . 绝对使用SOLR Solr uses lucene. Solr使用lucene。 this can we useful for a medium/big site.... 这可以用于中型/大型网站....

the good thing is you can request result in php serialized format from solr... 好的是你可以从solr请求php序列化格式的结果...

EDIT: 编辑:

this is what you are looking for, I complete forgot about it: Lucene Port To PHP by Zend 这就是你要找的东西,我完全忘了它: Zend的Lucene Port To PHP

I recently developed a suggestive fulltext search to use with my Zend Framework based web application - I couldn't find any ready-made solution that fit my requirements, so I went all out and developed a simple(fulltext) keyword search mechanism from scratch. 我最近开发了一个暗示全文搜索,用于我的基于Zend Framework的Web应用程序 - 我找不到任何符合我要求的现成解决方案,所以我全力以赴,从头开发了一个简单的(全文)关键字搜索机制。 I found the following articles helpful: 我发现以下文章很有帮助:

http://devzone.zend.com/node/view/id/1304 http://devzone.zend.com/node/view/id/1304

http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html

What I have now is a system that matches items based on a 'text summary' that is generated at the time the item is saved (or updated) in the database. 我现在拥有的是一个系统,它根据在数据库中保存(或更新)项目时生成的“文本摘要”来匹配项目。 I have a table called kw_search_summary that contains the text summary of each item (script generated), its id and its category id. 我有一个名为kw_search_summary的表,其中包含每个项目(生成的脚本)的文本摘要,其id和类别ID。 The 'summary' column is a mysql fulltext index, so I simply MATCH() the summary column AGAINST() a given expression, and display the results by relevancy. 'summary'列是一个mysql全文索引,所以我只是MATCH()一个给定表达式的汇总列AGAINST(),并按相关性显示结果。 The code that builds this query looks a bit like this: 构建此查询的代码看起来有点像这样:

    $select = $this->db->select()
                 ->from(array('kwi' => 'kw_search_index'),
                        array('id','prodcatid','itemid','useradid','summary','relevance' => "match(summary) against($safeExp in boolean mode)"))
                 ->where("match(summary) against($safeExp in boolean mode)")
                 ->order('relevance desc')
                 ->limitPage($currentPage,self::RESULTS_PER_PAGE);

Hope that was at least a bit helpful. 希望这至少有点帮助。

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

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