我正在尝试实施Zend_Search_Lucene
。我已经用以下条件实现了它:
但有时我收到错误为“Wildcard search is supported only for non-multiple word terms
”
下面是我要搜索的代码段,我是从控制器中获取的。
...
$browseSrArray = array();
if ($postData['name'])
$browseSrArray['name'] = preg_replace('#[^\w()/.%\-&]#', "", $postData['name']);
$results = $manufacturers->browseSearch($browseSrArray);
if(count($results)>0){
foreach ($results as $result) {
$doc = new Zend_Search_Lucene_Document();
// add Fields
$doc->addField(Zend_Search_Lucene_Field::Keyword('AccountNumber', $result['accountid']));
$doc->addField(Zend_Search_Lucene_Field::Keyword('ManufacturesName', strtolower($result['name'])));
$doc->addField(Zend_Search_Lucene_Field::Text('ContactName', $result['contact_name']));
$doc->addField(Zend_Search_Lucene_Field::Keyword('EmailId', strtolower($result['email'])));
$doc->addField( Zend_Search_Lucene_Field::Text('ManufacturesId', $result['manufacturer_id']));
$doc->addField(Zend_Search_Lucene_Field::Text('Manufacturesstatus', $result['status']));
// Add document to the index
$index->addDocument($doc);
}
// Optimize index.
$index->optimize();
if(strlen($postData['name']) > 2)
$query = Zend_Search_Lucene_Search_QueryParser::parse(strtolower($postData['name'].'*'));
else
$query = $postData['name'];
// Search by query
$this->view->hits = $index->find(strtolower($query));
} else {
$this->view->hits = 0;
}
...
需要修正以下条件。
例如,
testname-lastname
”,则会收到此错误。firstname lastname
”,那么当我搜索姓氏时,我将无法从lucence获得精确的LIKE结果。请帮我解决这个问题。