/** {@inheritdoc} */ public function toTwig() { $r = $this->getRequest(); $luceneIndex = Curry_Core::getSearchIndex(); $vars = array(); $vars['Total'] = $luceneIndex->numDocs(); if (isset($r->get['query'])) { $query = trim($r->get['query']); $hits = $luceneIndex->find($query); if ($this->alwaysWildcard && count($hits) === 0) { $hits = $luceneIndex->find($query . '*'); } $tmp = array(); if ($this->onlyThisLanguage) { foreach ($hits as $hit) { try { if ($hit->locale == Curry_Language::getLangCode()) { $tmp[] = $hit; } } catch (Zend_Search_Lucene_Exception $e) { $tmp[] = $hit; } } $hits = $tmp; } $vars['Query'] = $query; $vars['NumHits'] = count($hits); $vars['hits'] = new Curry_Twig_CollectionWrapper($hits, array($this, 'getHitProperties')); } return $vars; }
/** * Show index statistics. */ public function showStatistics() { $this->addMainMenu(); $index = Curry_Core::getSearchIndex(); $this->addMessage('Number of documents: ' . $index->numDocs()); $this->addMessage('Number of deleted documents: ' . ($index->count() - $index->numDocs())); $this->addMessage('Number of terms: ' . count($index->terms())); }