Zend Framework 2 Search Lucene?
Asked Answered
U

2

7

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

Uttermost answered 30/9, 2012 at 13:42 Comment(1)
possible duplicate of Lucene Search in zf2Pulido
C
10

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.

Caudad answered 30/9, 2012 at 14:57 Comment(1)
Can you please share any document or link how to implement it in zf2 will be great help.Needle
W
1

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.

Winni answered 17/10, 2016 at 13:36 Comment(1)
Regarding zf3, according to this issue github.com/zendframework/ZendSearch/issues/24 ZendSearch is abandoned and has problems on PHP7Hamby

© 2022 - 2024 — McMap. All rights reserved.