开发者

searching from database with zend search lucene

开发者 https://www.devze.com 2023-04-06 06:19 出处:网络
I am developing a social network kind o开发者_运维问答f web application. I want to enable my users to search for people. As I am using Zend framework, Zend search lucene looks like a nice choice to cr

I am developing a social network kind o开发者_运维问答f web application. I want to enable my users to search for people. As I am using Zend framework, Zend search lucene looks like a nice choice to create search functionality but there is no tutorial on web that can suit my needs. Is zend search written for searching from web pages only? Should I use Zend search or I should use simple like query and create the entire functionality my self?


Zend_Lucene is meant for every possible data . When you got raw data (like from database without in a special format .html or .doc) then you need to build your own document yourself . Which is good thing since it gives you lot more options

consider you got User table

<<User>>
*user_id
*email
*first_name
*last_name
*password


$userTb = new Default_Model_DbTable_User();
$index = Zend_Search_Lucene::create('/data/my-index');
$users = $userTb->fetchAll();
foreach($users as $user)
{
  $doc = new Zend_Search_Lucene_Document();
  $doc->addField(Zend_Search_Lucene_Field::Text('email', $user->email)); //here field = ur database column
  $doc->addField(Zend_Search_Lucene_Field::Text('first_name',$user->first_name)); 
  $index->addDocument($doc);

}
0

精彩评论

暂无评论...
验证码 换一张
取 消