Zend Lucene - 如何进行查询
我的创建索引函数如下所示
function create()
{
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive ());
$index = Zend_Search_Lucene::create('data/index');
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('title', 'a cheap car in town milage under 3000','utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('detail','a cheap car in town milage under 3000','utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('category', 'milage under 3000','utf-8'));
$index->addDocument($doc);
}
当用户搜索“城镇里程低于3000的廉价汽车”时,我会将查询分为
$query1 = "a cheap car";
$query2 = "in town";
$query3 = " milage under 3000";
我要搜索的
$query1 in field "title", $query2 in field "detail", $query3 in field "category".
3部分我也想搜索数字不区分大小写和文本不区分大小写。我该怎么做呢?我需要实际的代码,因为我对 Zend Lucene 文档完全感到困惑,我不知道要使用哪个代码或查询。
My create index function is as bellow
function create()
{
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive ());
$index = Zend_Search_Lucene::create('data/index');
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('title', 'a cheap car in town milage under 3000','utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('detail','a cheap car in town milage under 3000','utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('category', 'milage under 3000','utf-8'));
$index->addDocument($doc);
}
When user search for "a cheap car in town milage under 3000", I will split the query into 3 parts
$query1 = "a cheap car";
$query2 = "in town";
$query3 = " milage under 3000";
I want to search
$query1 in field "title", $query2 in field "detail", $query3 in field "category".
I also want to search number case insensitive and text case insensitive. How can I do it? I would need the actual code because I'm completely confused by the Zend Lucene docs, I don't know which code or query to use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的查询将是:
索引不区分大小写,除非在创建时明确设置为区分大小写。
your query will be:
Index is case-insensitive, unless explicitly set to case sensitive upon creation.