Zend Lucene 中的通配符查询
$index = Zend_Search_Lucene::open("/data/my_index1");
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('type','auto'));
$index->addDocument($doc);
$term = new Zend_Search_Lucene_Index_Term('auto*');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
$hits = $index->find($query);
foreach ($hits as $hit){
echo $hit->type;
}
这段代码执行成功后,需要打印auto。但数组 $hits 是空的。
这背后的原因是什么?
$index = Zend_Search_Lucene::open("/data/my_index1");
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('type','auto'));
$index->addDocument($doc);
$term = new Zend_Search_Lucene_Index_Term('auto*');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
$hits = $index->find($query);
foreach ($hits as $hit){
echo $hit->type;
}
After successful execution of this code, it needs to print auto. But array $hits is empty.
What is the reason behind this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
晚了两年,但可能的原因是您的更改未提交到索引。添加文档后,需要调用commit方法使其可供搜索。
Two years late, but the likely reason is that your changes are not committed to the index. After the document has been added, you need to call commit method to make it available for searching.
你可能不得不在这里迁就我,但是你是否尝试过将:替换
为
You might have to humour me here, but have you tried replacing:
with