/** * Gets the index mapped by the given lucene identifier. * * @param string $identifier The lucene identifier. * * @return \ZendSearch\Lucene\Index The lucene index. */ public function getIndex($identifier) { $config = $this->getConfig($identifier); $path = $config['path']; if (!$this->checkPath($path)) { $this->indexes[$identifier] = Lucene::create($path); } else { $this->indexes[$identifier] = Lucene::open($path); } Analyzer::setDefault(new $config['analyzer']()); $this->indexes[$identifier]->setMaxBufferedDocs($config['max_buffered_docs']); $this->indexes[$identifier]->setMaxMergeDocs($config['max_merge_docs']); $this->indexes[$identifier]->setMergeFactor($config['merge_factor']); ZfFilesystem::setDefaultFilePermissions($config['permissions']); if ($config['auto_optimized']) { $this->indexes[$identifier]->optimize(); } QueryParser::setDefaultEncoding($config['query_parser_encoding']); return $this->indexes[$identifier]; }
private function getIndex() : SearchIndexInterface { $path = $this->getIndexPath(); if (!$this->checkIndexPath($path)) { $index = Lucene::create($path); } else { $index = Lucene::open($path); } Analyzer::setDefault(new CaseInsensitive()); LuceneFilesystem::setDefaultFilePermissions(0775); QueryParser::setDefaultEncoding('UTF-8'); $index->setMaxBufferedDocs($this->options['max_buffered_docs']); $index->setMaxMergeDocs($this->options['max_merge_docs']); $index->setMergeFactor($this->options['merge_factor']); $index->optimize(); return $index; }