ZF1 had a gread search lucene implementation. is there something similar for ZF2? I can't find anything...
-
possible duplicate of [Lucene Search in zf2](http://stackoverflow.com/questions/12403475/lucene-search-in-zf2) – halfer Dec 02 '14 at 12:33
2 Answers
It is part of ZendSearch and you'll find it here https://github.com/zendframework/ZendSearch
If you drill down through the folders you'll find Lucene, but you'll probably need to install the whole thing following the instructions in the readme file on the first page I linked to.
Alternatively you can cd into your vendor directory and run:-
git clone https://github.com/zendframework/ZendSearch.git
That will create the ZendSearch module and you can then add it to your modules list in application.config.php
Also see the Zend Framework package repository.

- 18,120
- 9
- 61
- 77
-
2Can you please share any document or link how to implement it in zf2 will be great help. – Jeet Jan 28 '14 at 06:25
This is for Zend Framework 3 / Zend Search
The following code will get you started working 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);
It is worth noting however that at the time of writing Zend Search expects ErrorHandler:: to be available which is part of the Stdlib of Zend. I believe this has been removed from stdlib so I simply replaced these calls with a try/catch block.
Beyond the above example - the code in the ZF v1 manual provides a pretty good basis to work from in terms of functionality: https://framework.zend.com/manual/1.12/en/zend.search.lucene.overview.html.

- 3,875
- 30
- 32
-
1Regarding zf3, according to this issue https://github.com/zendframework/ZendSearch/issues/24 ZendSearch is abandoned and has problems on PHP7 – HappyDude May 26 '17 at 18:31