当我搜索“#”等特殊字符时,没有结果。
请注意,我已经转义了查询字符串。
但是,当与“c#”之类的字母组合时,Lucene 会找到该术语。
有没有办法搜索单个特殊字符?
这是我的片段:
Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(1);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(
new \Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
$index = Zend_Search_Lucene::create('/tmp/index');
$doc = new Zend_Search_Lucene_Document;
$doc->addField(Zend_Search_Lucene_Field::Text('title', 'Some Title Here', 'UTF-8'))
->addField(Zend_Search_Lucene_Field::Text('content-01', '+ @ #', 'UTF-8'))
->addField(Zend_Search_Lucene_Field::Text('content-02', 'C+ C#', 'UTF-8'));
$index->addDocument($doc);
$index->commit();
/* returns 0 results */
$r = $index->find("/#");
echo count($r) . "\n";
/* returns 1 results */
$r = $index->find('C#');
echo count($r) . "\n";
/* returns 1 results */
$r = $index->find('C+');
echo count($r) . "\n";