protected function indexComments() { $type_shortname = 'comment'; $spell_checker = new NateGoSearchPSpellSpellChecker('en_US', '', '', $this->getCustomWordList()); $comment_indexer = new NateGoSearchIndexer($type_shortname, $this->db); $comment_indexer->setSpellChecker($spell_checker); $comment_indexer->addTerm(new NateGoSearchTerm('fullname', 30)); $comment_indexer->addTerm(new NateGoSearchTerm('email', 20)); $comment_indexer->addTerm(new NateGoSearchTerm('bodytext', 1)); $comment_indexer->setMaximumWordLength(32); $comment_indexer->addUnindexedWords(NateGoSearchIndexer::getDefaultUnindexedWords()); $type = NateGoSearch::getDocumentType($this->db, $type_shortname); $sql = sprintf('select BlorgComment.* from BlorgComment inner join NateGoSearchQueue on BlorgComment.id = NateGoSearchQueue.document_id and NateGoSearchQueue.document_type = %s order by BlorgComment.id', $this->db->quote($type, 'integer')); $this->debug(Blorg::_('Indexing comments... ') . ' '); $comments = SwatDB::query($this->db, $sql, SwatDBClassMap::get('BlorgCommentWrapper')); $total = count($comments); $count = 0; foreach ($comments as $comment) { $ds = new SwatDetailsStore($comment); if ($count % 10 == 0) { $comment_indexer->commit(); $this->debug(str_repeat(chr(8), 3)); $this->debug(sprintf('%2d%%', $count / $total * 100)); } $document = new NateGoSearchDocument($ds, 'id'); $comment_indexer->index($document); $count++; } $this->debug(str_repeat(chr(8), 3) . Blorg::_('done') . "\n"); $comment_indexer->commit(); unset($comment_indexer); $sql = sprintf('delete from NateGoSearchQueue where document_type = %s', $this->db->quote($type, 'integer')); SwatDB::exec($this->db, $sql); }
protected function indexPhotos() { $spell_checker = new NateGoSearchPSpellSpellChecker('en_US', '', '', $this->getCustomWordList()); $photo_indexer = new NateGoSearchIndexer('photo', $this->db); $photo_indexer->setSpellChecker($spell_checker); $photo_indexer->addTerm(new NateGoSearchTerm('title', 5)); $photo_indexer->addTerm(new NateGoSearchTerm('tags', 2)); $photo_indexer->addTerm(new NateGoSearchTerm('description')); $photo_indexer->setMaximumWordLength(32); $photo_indexer->addUnindexedWords(NateGoSearchIndexer::getDefaultUnindexedWords()); $type = NateGoSearch::getDocumentType($this->db, 'photo'); $sql = sprintf('select PinholePhoto.title, PinholePhoto.id, PinholePhoto.description, PinholePhoto.image_set from PinholePhoto inner join NateGoSearchQueue on PinholePhoto.id = NateGoSearchQueue.document_id and NateGoSearchQueue.document_type = %s order by PinholePhoto.id', $this->db->quote($type, 'integer')); $this->debug(Pinhole::_('Indexing photos ... ') . ' '); $photos = SwatDB::query($this->db, $sql, SwatDBClassMap::get('PinholePhotoWrapper')); $total = count($photos); $count = 0; $current_photo_id = null; foreach ($photos as $photo) { $ds = new SwatDetailsStore($photo); $ds->title = $photo->getTitle(); $tags = ''; foreach ($photo->tags as $tag) { $tags .= ' ' . $tag->title . ' ' . $tag->name; } $ds->tags = $tags; if ($count % 10 == 0) { $photo_indexer->commit(); $this->debug(str_repeat(chr(8), 3)); $this->debug(sprintf('%2d%%', $count / $total * 100)); } $document = new NateGoSearchDocument($ds, 'id'); $photo_indexer->index($document); $current_photo_id = $photo->id; $count++; $sql = sprintf('delete from NateGoSearchQueue where document_type = %s and document_id = %s', $this->db->quote($type, 'integer'), $this->db->quote($photo->id, 'integer')); SwatDB::exec($this->db, $sql); } if (count($photos) > 0 && isset($this->memcache)) { $this->memcache->flushNs('photos'); } $this->debug(str_repeat(chr(8), 3) . Pinhole::_('done') . "\n"); $photo_indexer->commit(); unset($photo_indexer); }