【问题标题】:Cannot retrieve value from the Zend_Search_Lucene index无法从 Zend_Search_Lucene 索引中检索值
【发布时间】:2012-11-02 15:55:25
【问题描述】:
$index = Zend_Search_Lucene::create($indexpath);
$doc = Zend_Search_Lucene_Document_Html::loadHTMLFile ($targeturl);
$title = $doc->title;
$body = $doc->body;
$doc->addField(Zend_Search_Lucene_Field::Text('title', $title));
$doc->addField(Zend_Search_Lucene_Field::unStored('body', $body));
$doc->addField(Zend_Search_Lucene_Field::unIndexed('url', $targeturl));
$index->addDocument($doc);
$index->commit();

这就是我尝试使用 zend 创建索引的方式。这是通过名为 crawlerAction() 的操作完成的。

我试图从另一个名为 searchresultsAction() 的操作中获取数据;

$index = Zend_Search_Lucene::open($indexpath);
$hits =  $index->find($query);
foreach ($hits as $hit) 
{                   
    echo $hit->url;
    echo $hit->title; 
    echo $hit->body;
}

其中,$query 是搜索字符串。

我没有得到任何输出,我得到 $hits 作为一个空数组。 我不确定到目前为止我是否在代码中犯了任何错误。这是我第一次使用 zend 进行搜索。谁能指出哪里出了问题?

【问题讨论】:

    标签: php zend-framework lucene zend-search-lucene


    【解决方案1】:

    我会用Luke 查看索引,看看我的索引操作是否成功完成。

    【讨论】:

      猜你喜欢
      • 2012-04-12
      • 2010-10-11
      • 2010-12-01
      • 2016-11-02
      • 2020-06-20
      • 1970-01-01
      • 1970-01-01
      • 2019-01-23
      • 2012-05-06
      相关资源
      最近更新 更多