Jump to content

about Zend_Search_Lucene()

- - - - -

  • Please log in to reply
No replies to this topic

#1
leeyo

leeyo

    Newbie

  • Members
  • PipPip
  • 12 posts
It's my codes,
'title' include value '55',but while searching with 55 there apear nothing.

<?php


require_once 'Zend/Controller/Action.php';


class SearchController extends Zend_Controller_Action{

	

        public function indexAction() {

        	if($this->getRequest()->isGet()){

		      $index = new Zend_Search_Lucene('data/index'); 

		      $getData = $this->getRequest()->getQuery();

		      if(!empty($getData['keywords'])) {	

             //$keywords = strtolower($getData['keywords']);

             $keywords = $getData['keywords'];

              $hits = $index->find($keywords);

              foreach ($hits as $hit) {  	

              echo $hit->title;

              

            }

           }

         }

       }

			

	  public function createindexAction(){

          $index = new Zend_Search_Lucene('data/index', true);//建立索引对象,TRUE表示一个新的索引

          $news = new Default_Model_DbTable_News();

          $result = $news->fetchAll();

          foreach($result as $row){   	

	      $doc = new Zend_Search_Lucene_Document();//建立一个索引文档

          $doc->addField(Zend_Search_Lucene_Field::Text('filename',$row->filename,'utf-8'));

          $doc->addField(Zend_Search_Lucene_Field::Text('title', $row->title,'utf-8'));

          $doc->addField(Zend_Search_Lucene_Field::unIndexed('publishTime', $row->publishTime));

          $index->addDocument($doc); //将这个文档加到索引中

          }

          $index->commit();//提交,保存索引资料

      }

}





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users