Пример #1
0
 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);
 }