On Sun, Apr 6, 2008 at 10:00 PM, Brian Levine <[EMAIL PROTECTED]> wrote:
>
>
>
>  > Date: Sat, 5 Apr 2008 14:30:07 -0400
>  > From: [EMAIL PROTECTED]
>  > To: [email protected]
>  > Subject: Re: Custom Search
>
>
> >
>  > On Fri, Apr 4, 2008 at 10:50 AM, Brian Levine <[EMAIL PROTECTED]> wrote:
>  > >  Has anyone had any luck in implementing a custom search?
>  > >
>  > >  I'm interested in searching not just blog entries, but also some other 
> fields that are in my DB.  I checked out the manuals and dug around in the 
> code a bit (only found search plugins for google and wiki, but those seem to 
> be something else).  There doesn't seem to be any hooks in for adding my own 
> search functionality.  Does this sound right?
>  >
>  > Yes, unfortunately that is correct. There is currently no search plugin 
> facility
>  >
>  > >  Since I don't want to change roller source because that would make 
> upgrades/updates a PIA, my current plan is to write a new search servlet to 
> handle what I want to do.  But I still want to keep everything within the 
> roller framework (if that makes sense).  So, I'm also going to extend 
> PageModel to be able to display the results in a different way -- because I'm 
> going to be displaying more than blog entries.  And then right my own 
> velocity template for rendering the page.  And it looks like I'll have to 
> implement my own pager since as I mentioned before I'll be returning results 
> that contain more than blog entries.
>  >
>  > Create your own page models to display your new search results sounds
>  > like a good idea.
>  >
>  > Question are: 1) how do you hook-in to ensure that you index the
>  > things you want to index and 2) how do return your search results so
>  > that they can be included in Roller-generated blog pages and feeds.
>  >
>  > Roller's backend is defined by a set of Java "manager" interfaces that
>  > create, retrieve, update and delete plain old Java objects or POJOs.
>  > The implementations of these interfaces are specified in Roller's
>  > Guice module file, which is called JPAWebloggerModule. By creating
>  > your own module class and plugging it in via roller-custom.properties,
>  > you can replace Roller's managers with your own implementations and
>  > even add entirely new managers.
>  >
>  > Override this property and substitute your own module, naming your
>  > implementations:
>  >    
> guice.backend.module=org.apache.roller.weblogger.business.jpa.JPAWebloggerModule
>  >
>  > So, the answer to question #1 might be for you to override Roller's
>  > WeblogEntryManager with your own implementation, one that extends
>  > Roller's just to hook in your index operations every time an entry is
>  > saved, updated or deleted.
>  >
>  > For question #2, you might add your own new SearchManager interface
>  > with methods that return your new extended seach operations.
>  >
>  > Oh, and one thing to be aware of that Roller's Lucene implementation
>  > will not scale well, i.e. it won't work in a scenario where you have
>  > more than one instance of Roller running.
>  >
>  > - Dave
>
>  Dave, thanks for your response!
>
>  For question #1:  After taking a look at the Guice file you mentioned, I 
> think I can get away with overriding IndexManagerImp (and pointing to the new 
> implementation in the Guice file), since I don't need to change how blog 
> entries are stored and indexed (I know, not very clear from my description).  
>  Instead, I want to be able to search blog entries and I have other documents 
> that I want to search.  So I'll probably set up a second Lucene index for 
> these different kinds of documents.  Then I'll  override the classes that are 
> in the org.apache.roller.weblogger.business.search.operations package (or 
> write new classes for the second Lucene index).
>
>  For quesiton #2: I think I'm okay here.  The extra, umm, stuff that I want 
> people to be able to search for, shouldn't be displayed in feeds.  The 
> documents are web pages on other, external websites (it's a niche search 
> engine).  Is search being used in other places (besides the feeds), like 
> where you display blog entries by category?  Or someplace else?
>
>  Scalability: Am I going to have trouble running lucene in a hosted 
> environment where other accounts on the same machine are running roller?  
> Will it be slow, or will it not work at all?

No. The problem will occur if you have two instances of the Roller web
app operating against the same database. Those two instances cannot
write to the same Lucene index because they'll have a conflict writing
to the same set of files. And each instance maintains it's own index,
then those indexes will get out of sync.

- Dave

Reply via email to