【问题标题】:zend lucene how set priority on keyword fieldzend lucene 如何在关键字字段上设置优先级
【发布时间】:2013-03-23 10:20:55
【问题描述】:

可以为某些关键字字段设置永久的revelance奖励吗? 我有产品名称字段、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 和 结果必须是这样的: 最大重合最大优先级, 最大重合下一个优先级, 最大重合下一个优先级

【问题讨论】:

    标签: zend-framework search lucene indexing


    【解决方案1】:

    是的,可以在评分的情况下为某个字段设置永久奖励。

    这里是Tutorial

    我不确定这个 zend Lucene,但是 Field.setBoost() 方法是我们在普通 Lucene 中所做的。我敢肯定,zend Lucene 必须有一种等效的方法,因为这是一个基本功能。

    以下是上述教程中的sn-p。

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

    我无法保证上述sn-p的有效性,但希望对您有所帮助。

    【讨论】:

    • 如果我只存储该字段但不使用该字段进行搜索,我需要做什么?第二个问题——我怎样才能得到每个元素的revelance,我从find中得到什么?
    • 我做 $boostField=Zend_Search_Lucene_Field::text('priority',$word['priority']); $boostField->boost=1.5; $doc->addField($boostField);但它不起作用。我不在搜索该字段中使用。该字段只是存储并为搜索结果提供了提升奖励
    • 你说的“它没有用”是什么意思?请详细说明您的要求。
    • 我只存储有关优先级的信息。我搜索时不使用该信息。在“优先级”字段中,我只有数字——结果如何优于另一个结果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多