What is the best way to integrate the popularity factor correctly with zend-search lucene?

I read this one and I'm still a little confused on how to do this.

I have an unindexed field that counts the number of votes for the set of search lists that are being viewed. The main search works fine, but I also want to include the voting field as part of the algorithm, and I'm not sure how to include the non-indexed field in it. Can anyone suggest any guide or example?

+4
source share
1 answer

You do not have to adapt the scoring algorithm (which implements tf-idf btw).

If you just want to integrate the number of views into the scoring, you can β€œincrease” the search document before adding it to the index, for example:

$doc = new Zend_Search_Lucene_Document(); $boostFactor = 0.1; $doc->boost = (float)$numberOfVotes * $boostFactor; // .. $index->addDocument($doc); $index->commit(); 

The increase factor in this example is not significant, since you have only one increase criterion. If you want to increase non-linearity, you can also use exp or sqrt on $ numberOfVotes.

But another question:

Why not use ElasticSearch (or another search engine) in the first place?

ElasticSearch, for example. is more powerful and faster than the PHP implementation of Zend Lucene. In addition, it is very easy to connect a scoring mechanism, for example. http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query.html You can use a PHP client, for example Elastica with it.

+1
source

All Articles