我正在http://demos.zatechcorp.com/codeigniter/上处理该应用程序
在我的机器上运行的当前版本中,我在 Codeigniter 中加载了 ZendFramework,并生成了一个索引,如下所示:
// ... Some code that loads all the markets
foreach ($markets as $market)
{
$doc = new Zend_Search_Lucene_Document();
// Id for retrieval
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', $market->id));
// Store document URL to identify it in search result.
$doc->addField(Zend_Search_Lucene_Field::Text('url', $market->permalink));
// Index document content
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $market->description));
// Title
$doc->addField(Zend_Search_Lucene_Field::Text('title', $market->title));
// Phone
$doc->addField(Zend_Search_Lucene_Field::Keyword('phone', $market->phone));
// Fax
$doc->addField(Zend_Search_Lucene_Field::Keyword('fax', $market->fax));
// Street
$doc->addField(Zend_Search_Lucene_Field::Keyword('street', $market->street));
// City
$doc->addField(Zend_Search_Lucene_Field::Keyword('city', $market->city));
// State
$doc->addField(Zend_Search_Lucene_Field::Keyword('state', $market->state));
// Zip
$doc->addField(Zend_Search_Lucene_Field::Keyword('zip', $market->zip));
// Type
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('type', 'market'));
// Store Document
$index->addDocument($doc);
}
在我的搜索中,我这样做:
$hits = $index->find($q);
这适用于简单的单词,但是当我想进行像“Sheba Foods”(包括引号)这样的搜索时,它会返回一个结果,但结果是错误的,甚至没有“Sheba”这个词。
我放弃了 MySQL 全文搜索,因为它存在明显的问题,并且无法在这方面取得任何进展。
我一直在看Zend_Search_Lucene_Search_QueryParser::parse()
方法。答案就在这个方法里吗?