Jump to content

[SOLVED] zend search lucene


chaiwei

Recommended Posts

Hi,

 

Yesterday I came across zend search lucene,

It is faster than database query if I am not mistaken.

 

My question is ,

what if I stored all the data using apache lucene instead of database?

 

I only have little knowledge on it. Can some one explain briefly for me please?

Thanks.

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.