private function getLucene() { if ($this->lucene) { return $this->lucene; } try { $this->lucene = ZendSearch\Lucene\Lucene::open($this->directory); } catch (ZendSearch\Lucene\Exception\ExceptionInterface $e) { $this->lucene = ZendSearch\Lucene\Lucene::create($this->directory); } global $prefs; if (!empty($prefs['unified_lucene_max_buffered_docs'])) { // these break indexing if set empty $this->lucene->setMaxBufferedDocs($prefs['unified_lucene_max_buffered_docs']); // default is 10 } if (!empty($prefs['unified_lucene_max_merge_docs'])) { $this->lucene->setMaxMergeDocs($prefs['unified_lucene_max_merge_docs']); // default is PHP_INT_MAX (effectively "infinite") } if (!empty($prefs['unified_lucene_merge_factor'])) { $this->lucene->setMergeFactor($prefs['unified_lucene_merge_factor']); // default is 10 } ZendSearch\Lucene\Lucene::setResultSetLimit($this->resultSetLimit); return $this->lucene; }
private function getIndex($rebuld = false) { if ($rebuld || $this->indexNeedsRebuilding()) { $index = ZendSearch\Lucene\Lucene::create($this->indexFile); foreach ($this->getReceivedDataLatest() as $connection) { $data = json_decode($connection['data'], true); if ($data) { $doc = $this->indexConnection($connection['created'], $data); $index->addDocument($doc); } } $index->optimize(); return $index; } return ZendSearch\Lucene\Lucene::open($this->indexFile); }