views:

238

answers:

2

What are the best practices to configure Zend Lucene to make the search results more relevant?

i have the following fields and document type

 productname (Text)
 description (Text)
 category (Keyword)

Please give some sample codes.

A: 

Getting relevant result from any search engine is hard work. With the level of detail you specify, it is hard to give you any specific advice. I suggest you start with this paper.

Yuval F
A: 

There are two concepts that come to my mind with your question, yet not sure exactly what you're looking for.

Score: A rating that indicates to what extent a document matches the search query. From the manual:

Zend_Search_Lucene uses the same scoring algorithms as Java Lucene. All hits in the search result are ordered by score by default.

$hits = $index->find($query);
foreach ($hits as $hit) {
    echo $hit->id;
    echo $hit->score;
}

The score is by default retrieved and applied to order the results from more to less relevant, thus it must be assumed that you need something else.

Term Boosting: Used to influence the relevance of individual terms within a query. Quoting once more the manual:

Boosting allows you to control the relevance of a document by boosting individual terms. For example, if you are searching for

PHP framework

and you want the term "PHP" to be more relevant boost it using the ^ symbol along with the boost factor next to the term. You would type:

PHP^4 framework

This will make documents with the term PHP appear more relevant. You can also boost phrase terms and subqueries as in the example:

"PHP framework"^4 "Zend Framework"

Does this help at all?

nuqqsa