Issues

ZF-4581: Search query with escaped special character doesn't work

Description

Reproducible with the following code:

<?php

require_once('Zend/Search/Lucene.php');

$index = Zend_Search_Lucene::create('/tmp/index');

$doc = new Zend_Search_Lucene_Document;
$doc->addField(Zend_Search_Lucene_Field::Text('title', 'test123', 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('contents', 'test huhu ? 123', 'UTF-8'));
$index->addDocument($doc);
$index->commit();

/* returns 0 results */
$r = $index->find('\\');
echo count($r) . "\n";

/* returns 0 results */
$r = $index->find('\\?');
echo count($r) . "\n";

/* returns 0 results */
$r = $index->find('123');
echo count($r) . "\n";

/* returns 1 result */
$r = $index->find('huhu');
echo count($r) . "\n";

The first search query produces a PHP notice:

PHP Notice:  Undefined offset:  1 in /opt/sevenval/fit80/lib/php/Zend/Search/Lucene/Search/QueryLexer.php on line 477

The second and the third queries don't return any results.

Comments

Whe have the same problem : we can't search for the string "c++" in our documents. The query $index->find('c++') returns exactly the same results than the query $index->search('c++')