Search code examples
phpzend-frameworksearchfull-text-searchsearch-engine

Fulltext search with PHP and Zend Framework - Lucene?


Hey I am looking for a way to do search in our application written in PHP and with the Zend Framework. The problem I want to fix is that some people write "Windows 95" and others "Windows95" again others "Win 95" or "Win95". I have read that there is the Zend_Search_Lucene Module but don't know if that is the right way to go.

Do you have ideas? It should be written in PHP and should scale well so centralized storage would be extremly nice.


Solution

  • Well ,

    my answer have nothing to do with Zend_Lucene because from my point of view ,

    I love the way doctrine implement its fulltext search they name it Text Analyzers , take a look :

    By default Doctrine uses Doctrine_Search_Analyzer_Standard for analyzing the text. This class performs the following things:

    Strips out stop-keywords (such as 'and', 'if' etc.) As many commonly used words such as 'and', 'if' etc. have no relevance for the search, they are being stripped out in order to keep the index size reasonable. Makes all keywords lowercased. When searching words 'database' and 'DataBase' are considered equal by the standard analyzer, hence the standard analyzer lowercases all keywords. Replaces all non alpha-numeric marks with whitespace. In normal text many keywords might contain non alpha-numeric chars after them, for example 'database.'. The standard analyzer strips these out so that 'database' matches 'database.'. Replaces all quotation marks with empty strings so that "O'Connor" matches "oconnor"

    source http://www.doctrine-project.org/projects/orm/1.2/docs/manual/searching/en#introduction

    I guess you can prepare your query before passing it to lucene and before creating your index