ZF-4706: Escaping does not work for * and ?

Description

Steps to reproduce:


require_once 'Zend/Search/Lucene.php';

$index = Zend_Search_Lucene::create('temp');

$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::text('foo', 'Docu*ent'));
$index->addDocument($doc);

$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::text('foo', 'Document'));
$index->addDocument($doc);

$q = '+foo:Docu\*ent';
echo '$q = ' . $q . "\n";
$hits = $index->find($q);
foreach ($hits as $hit) {
    echo $hit->foo . "\n";
}

$q = '+foo:Docu*';
echo '$q = ' . $q . "\n";
$hits = $index->find($q);
foreach ($hits as $hit) {
    echo $hit->foo . "\n";
}

Excepted result:


$q = +foo:Docu\*ent
Docu*ent
$q = +foo:Docu*
Document
Docu*ent

Actual result:


$q = +foo:Docu\*ent
Document
$q = +foo:Docu*
Document
Docu*ent

Comments

This is the same type of issue.