Extending / changing how Zend_Search_Lucene searches

Posted by Grant Collins on Stack Overflow See other posts from Stack Overflow or by Grant Collins
Published on 2010-05-12T12:21:52Z Indexed on 2010/05/12 12:24 UTC
Read the original article Hit count: 203

Hi,

I am currently using Zend_Search_Lucene to index and search a number of documents currently at around a 1000 or so. What I would like to do is change how the engine scores hits on a document, from the current default.

Zend_Search_Lucene scores on the frequency of number of hits within a document, so a document that has 10 matches of the word PHP will score higher than a document with only 3 matches of PHP. What I am trying to do is pass a number of key words and score depending on the hits of those keywords. e.g.

I pass 5 key words say,PHP, MySQL, Javascript, HTML and CSS that I search against the index. One document has 3 matches to those key words and one document has all 4 matches, the 4 matches scores the highest. The number of instances of those words in the document do not concern me.

Now I've had a quick look at Zend_Search_Lucene_Search_Similarity however I have to confess that I am not sure (or that bright) to know how to use this to achieve what I am after.

Is what I want to do possible using Lucene or is there a better solution out there?

© Stack Overflow or respective owner

Related posts about lucene

Related posts about zend-framework