Rogerle (1) [Avatar] Offline
#1
Rob, in chapter 9, you do a great job of explaining how to setup and use Zend_Lucene.

I would have not thought of using the Observer pattern until you mentioned it!

As you explain in the book, this "future proofs" us so we can add more models into Lucene.

I am currently working on search for an inventory checkout system.

So for simplicity assume I have books, DVDs, Blu-Ray discs, Publishers, and Authors

I'd like my users to be able to search by media type, Publishers and Authors. (I was thinking of in a drop down menu)

From a architectural standpoint, how do I go about adding different documents to the Lucene index?

Would I need to divide each media type in it's own subfolder or can the lucene index handle documents of different model definitions?

Example:
lucene_index
--dvds
--books
--blu_ray


Or is Lucene nicer than that and I can do

$doc = new Zend_Search_Lucene_Document();
switch( $media_type )
{
case dvds:
//create document for DVD Model
$doc->addField() etc etc
break;

case books;
//book fields
break;
}

$index->addDocument($doc);


All the examples of Lucene I have seen only add one Model into the Lucene Index. And it was usually for a blog or news article site of some sort.

If you could shed some light that would be great.

In addition, I have been using Luke a Java based Lucene tool to view my lucene_index, http://www.getopt.org/luke/, hopefully that is helpful to someone else.
akrabat (479) [Avatar] Offline
#2
Re: Using Lucene with Multiple Models
A lot depends on whether you need to search across types at any point. If you put them in separate indexes it gets harder to do so.

Personally, I'd just use a keyword for the media type and then programatically add that as a criteria when doing searching.

Regards,

Rob...