Question

ZF1 had a gread search lucene implementation. is there something similar for ZF2? I can't find anything...

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top