2013-03-23 33 views
1

有可能爲某些關鍵字字段設置永久的revelance類型的獎勵嗎? 我有產品名稱字段,id關鍵字字段和優先關鍵字字段。我想設置結果的目標,如搜索的結果+結果的優先級。zend lucene如何設置關鍵字字段的優先級

//id of product 
    $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId(), "utf-8")); 

    //i want set permanent revelance bonus on that field 
    $doc->addField(Zend_Search_Lucene_Field::Keyword('priotity', "priority", "utf-8")); 

    //field for search 
    $doc->addField(Zend_Search_Lucene_Field::UnStored('description', $this->getDescription(), "utf-8")); 

比如我搜索蘋果iPhone和 結果一定是這樣的: 最大符合最高優先級, 最大符合下一個優先級, 最大符合下一個優先

回答

2

是的,這是可以設置永久在得分情況下的場上獎金。

這裏是Tutorial

我不知道這個Zend的Lucene的,但該方法Field.setBoost()是我們純Lucene的怎麼辦。我敢肯定,Zend Lucene必須有相同的方式來完成它,因爲這是一個基本功能。

以下是上述教程的片段。

$field = Zend_Search_Lucene_Field::Text('firstname', $this->getFirstname()); 
    $field->boost = 1.5; 

我無法保證上述代碼段的有效性,但我希望它對您有所幫助。

+0

如果我只存儲該字段,但不搜索該字段,我需要做什麼?第二個問題 - 我如何能夠揭示每一個元素,我從中找到什麼? – 2013-03-24 13:14:30

+0

我做 $ boostField = Zend_Search_Lucene_Field :: text('priority',$ word ['priority']); $ boostField-> boost = 1.5; $ doc-> addField($ boostField); 但它不起作用。我不用於搜索該字段。該字段只是存儲並給搜索結果提供了加值獎金 – 2013-03-25 06:37:41

+0

「它沒有工作」是什麼意思?請詳細說明您的要求。 – phani 2013-03-26 03:51:22