This is for Zend Framework 3 / Zend Search
The following code will help you get started with Zend Search:
use ZendSearch\Lucene\Lucene; use ZendSearch\Lucene\Document; use ZendSearch\Lucene\Document\Field; use ZendSearch\Lucene\MultiSearcher; $index = Lucene::create($path_to_index); // or use open to update an index $document = new Document; $document->addField(Field::Text($key,$value)); $index->addDocument($document); $search = Lucene::open($path_to_index); $search->find($str);
However, it is worth noting that at the time of writing, Zend Search expects ErrorHandler :: to be available, which is part of Stdlib of Zend. I believe this was removed from stdlib, so I just replaced these calls with a try / catch block.
In addition to the above example, the code in the ZF v1 manual provides a good basis for working in terms of functionality: https://framework.zend.com/manual/1.12/en/zend.search.lucene.overview.html .
Antony
source share