Jump to content

Zend search?


Bman900

Recommended Posts

Lucene is designed around the idea that its searching and indexing documents.  Lucene indexes fields that you choose in the document to base its index on.  Say I have a website with recipes, so my pages consist of the fields with the name, date added, ingreditents list, instructions and another field with the location/url.  I have to feed Lucene that data in the form of a document (Zend_Search_Lucene_Document) in order for those to get added to the index.

 

Given that you probably already have a website, create a simple crawler to iterate through your existing data, create Lucene documents with the fields you wish added to the Lucene index.  You'll also want to create a class/script/plugin to trigger after data has been added or updated to your site to keep the Lucene index current. There is no update in lucene, you delete the document and then re-add it to the index.  Its largely up to you where you add to the index.

 

Zend Presentation on Implementing Zend_Search_Lucene

Link to comment
Share on other sites

Wow thank you for the info. It seems easy in theory but getting down to it is impossible for some one who is new to the framework. I have tried creating the spider in your link but for some reason it keeps giving me errors with the include files. Till I finaly get the hang of this framework more, is there another way of creating a search of my site with Zend?

Link to comment
Share on other sites

Well I got mad and decided not to give up. So far I actualy got a way of indexing newly added articled but the trouble comes in when I need to update them. I understand I have to delete the document and re ad it. Am fine with the re adding but the deletion deletes everything!

 

$index = Zend_Search_Lucene::open('index');


		$removePath = 'article/view/' . $id;
		$hits = $index->find('url:' . $removePath);
		foreach ($hits as $hit) {
    		$index->delete($hit->id);
		$index->commit();

 

Any ideas why its deleting everything in the index and rather no the documents that match my remove path?

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.