Jump to content

[SOLVED] zend search lucene


chaiwei

Recommended Posts

okay.

 

So when I create a article using tinyMCE and save it into database.

Normally when I search, I usually query my database.

 

But now if I wan to use lucene to create index.

So I insert the article into database, and I using zend lucene, Insert again?

 

I saw someone code like this:

 
<?php
  require_once 'Zend/Search/Lucene.php';
  $index = Zend_Search_Lucene::open("/var/www/lucene-data/blog-index"); 

  $doc = new Zend_Search_Lucene_Document();  

  $doc->addField(Zend_Search_Lucene_Field::Keyword('url',"http://ganeshhs.com/url-3"));  

  $doc->addField(Zend_Search_Lucene_Field::UnIndexed('articleId', 3));  

  $doc->addField(Zend_Search_Lucene_Field::UnIndexed('postedDateTime',"20007-12-29 01:40:00"));  
  $doc->addField(Zend_Search_Lucene_Field::Text('title',"Porting PHP to Javascript : php js"));  

  $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', "During graduation got interested in web technology, to kick start i started reading html, javascript.")); 

  $doc->addField(Zend_Search_Lucene_Field::Text('category', "Javascript"));  

  $index->addDocument($doc);  

  $index->commit();  

  $index->optimize();  

So I insert into database first then only I create index using above code?

Then when the time we search, We search for the keyword using lucene, then Get the url from lucene, and using php header jump to that page and retrieve article from database again. right?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.