zend lucene如何设置关键字字段的优先级

时间:2013-03-23 10:20:55

标签: zend-framework search lucene indexing

可以为某些关键字字段设置永久性的奖励吗? 我有产品名称字段,id关键字字段和优先级关键字字段。我想设置一些结果,比如搜索的结果和结果的优先级。

 //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和 结果必须如下: 最大重合最大优先级, 最大巧合下一个优先事项, 最大巧合次优先

1 个答案:

答案 0 :(得分:2)

是的,可以在评分的上下文中为字段设置永久奖金。

以下是Tutorial

我不确定这个zence Lucene,但方法Field.setBoost()就是我们在朴素Lucene中的表现。我确信必须有一个与zend Lucene相同的方法,因为这是一个基本功能。

以下是上述教程的摘录。

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

我无法保证上述代码段的有效性,但我希望它对您有所帮助。