Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0.2
-
Fix Version/s: 1.8.0
-
Component/s: Zend_Search_Lucene
-
Labels:None
-
Fix Version Priority:Nice to Have
Description
Numerical values e.g. phone number are not searcheable. The field types "text", "keyword" and "unstored" are tested. The TestCase for PHPUnit exploits the problem:
<?php
set_include_path('.' . PATH_SEPARATOR . '/opt/lampp/lib/php/' . PATH_SEPARATOR . '../application/library/');
require_once 'PHPUnit/Extensions/PerformanceTestCase.php';
require_once 'Zend/Search/Lucene.php';
require_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
/**
* This TestCase tests the search beavior in fields of type "keyword",
* "text" and "unstored".
*/
class BugExploitTest extends PHPUnit_Extensions_PerformanceTestCase{
private $index = null;
// private $numericalValue = 'Zziqwez'; // found in fields of any type
// private $numericalValue = 'Hallowe'; // not found in field of type "text". why?
private $numericalValue = '12345678'; // not found
/**
* Creates an index and adds a document to it.
*/
protected function setUp() {
try{
$this->index = Zend_Search_Lucene::open("/tmp/index");
}catch(Exception $e){
$this->index = Zend_Search_Lucene::create("/tmp/index");
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('keyword', $this->numericalValue));
$doc->addField(Zend_Search_Lucene_Field::Text('text', $this->numericalValue));
$doc->addField(Zend_Search_Lucene_Field::UnStored('unstored', $this->numericalValue));
$this->index->addDocument($doc);
}
/**
* Shuting down the index
*/
protected function tearDown() {
$this->index->commit();
unset($this->index);
}
/**
* Searching in the field of type "keyword".
* Our index should have one document at least.
*/
public function testSearchKeyword(){
$this->searchInField('keyword');
}
/**
* Searching in the field of type "text".
* Our index should have two documents at least.
* (tearDown non't deleletes any dokument)
*/
public function testSearchText(){
$this->searchInField('text');
}
/**
* Searching in the field of type "unstored".
* Our index should have two documents at least.
* (tearDown non't deleletes any dokument)
*/
public function testSearchUnStored(){
$this->searchInField('unstored');
}
private function searchInField($fieldName){
$userQuery = Zend_Search_Lucene_Search_QueryParser::parse($this->numericalValue);
Zend_Search_Lucene::setDefaultSearchField($fieldName);
$hits = $this->index->find($userQuery);
// after adding a document we expect one search result at least
$this->assertNotEquals(0, count($hits));
}
}
?>
Assigned to Alexander