当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Search_Lucene_Document::AddField方法代码示例

本文整理汇总了PHP中Zend_Search_Lucene_Document::AddField方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Document::AddField方法的具体用法?PHP Zend_Search_Lucene_Document::AddField怎么用?PHP Zend_Search_Lucene_Document::AddField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Search_Lucene_Document的用法示例。


在下文中一共展示了Zend_Search_Lucene_Document::AddField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: IndexBug

 public function IndexBug($bug)
 {
     $this->RemoveBug($bug->bug_id);
     $doc = new Zend_Search_Lucene_Document();
     $doc->AddField(Zend_Search_Lucene_Field::Keyword('bug_id', $bug->bug_id));
     $doc->AddField(Zend_Search_Lucene_Field::Text('title', $bug->title));
     $doc->AddField(Zend_Search_Lucene_Field::Keyword('reporting_user_id', $bug->reporting_user_id));
     $doc->AddField(Zend_Search_Lucene_Field::Keyword('reporting_date', $bug->reporting_date));
     // We concatenate all comments into a single text blob. We only show
     // hits as bugs, but we want comment content to matter.
     $comment_blob = '';
     $stmt = Bugdar::$db->Prepare("SELECT body FROM " . TABLE_PREFIX . "comments WHERE bug_id = ? ORDER BY comment_id");
     $stmt->Execute(array($bug->bug_id));
     while ($comment = $stmt->FetchObject()) {
         $comment_blob .= $comment->body . "\n\n";
     }
     $doc->AddField(Zend_Search_Lucene_Field::UnStored('comments', $comment_blob));
     // Add all attributes.
     $stmt = Bugdar::$db->Prepare("SELECT * FROM " . TABLE_PREFIX . "bug_attributes WHERE bug_id = ?");
     $stmt->Execute(array($bug->bug_id));
     $tags = array();
     while ($attr = $stmt->FetchObject()) {
         if ($attr->attribute_title) {
             $doc->AddField(Zend_Search_Lucene_Field::Keyword($attr->attribute_title, $attr->value));
         } else {
             $tags[] = $attr->value;
         }
     }
     $doc->AddField(Zend_Search_Lucene_Field::Text('tag', implode(' ', $tags)));
     $this->lucene->AddDocument($doc);
 }
开发者ID:rsesek,项目名称:Bugdar2,代码行数:31,代码来源:search_engine.php


注:本文中的Zend_Search_Lucene_Document::AddField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。