php Zend_Search_Lucene 查询索引没有结果
创建索引的过程
<?php
/****************************/
//Desinged By Robby
//2009-3-21
/****************************/
require_once 'Zend/Search/Lucene.php';
if (function_exists("set_time_limit") && ! get_cfg_var(’safe_mode’)) {
set_time_limit(0);
}
$index = Zend_Search_Lucene::create('index');//建立索引对象,TRUE表示一个新的索引
$row=array('11','22','33','44','55','66','77','88','99','100');
//while($row=$db->fetch_row($query)){
foreach($row as $key){
$doc = new Zend_Search_Lucene_Document(); //建立一个索引文档
$doc->addField(Zend_Search_Lucene_Field::Text('address', $key));
$index->addDocument($doc); //将这个文档加到索引中
}
$index->commit();//提交,保存索引资料
?>
查询索引的过程
<?php
require_once 'Zend/Search/Lucene.php';
$str = <<< EOT
<form name="form1" method=get action="">
<label>
<input type="text" name="keywords" id="keywords">
</label>
<label>
<input type="submit" name="button1" id="button1" value="search">
</label>
</form>
EOT;
echo $str;
if(!empty($keywords)) {
$index = Zend_Search_Lucene::open('index'); //索引存放的路径
$keywords =strtolower($_GET['keywords']);
$hits = $index->find($keywords);
foreach ($hits as $hit) {
echo "小区地址:".$hit->address.'<br>';
}
}
?>
如题
我在先显示的文本框中输入11和1,其他的在数组中的内容都没有显示结果。请问怎么回事》能不能给出原因。或者
能够调试成功的源代码!
小弟在此先谢谢各位大哥大姐!