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
