Hi
I added (hopefully) general purpose search engine interfaces to the
Turbine Services. I also added an implementation for an open-source search
engine - Lucene (lucene.sourceforge.net - i think :-) otherwise just do a
search for lucene on www.sourceforge.net Finally I did a webmacro test
screen, to see how everything works (no problems there).
Would it be possible to add this interfaces (and maybe a the default lucene
implementation) to the Turbine project? I know this might be a lot to ask,
but I believe that this would really add some value to the framework,
especially since almost *all* web-applications require some sort of
information retrieval mechanism.
I am also working an implementations for other engines like Excalibur
Retrievalware (very powerful but unfortunately a bit expensive :-).
Regards
Leon
Proposed interfaces:
// Interface to a search engine
public interface Search
{
public boolean init (String username, String password);
public boolean setLibrary (String library);
// Get/Set of search engine parameters e.g. spell checkers, max results,
etc.
public void put (String name, String value);
public String get (String name);
public boolean doSearch (String query, int type);
public Enumeration getResults();
}
// A single "hit" from the search engine ( Returned by getResults() )
public interface SearchResult {
// return a field value
public String get (String fieldname);
// Get all the available fields
public Enumeration getFields();
}
// Webmacro Search.java
public void doBuildTemplate( RunData data, WebContext context )
{
context = getContext(data);
String querystring = data.parameters.getString ("querystring");
if (querystring != null) { // If we get a querystring do a
search
org.apache.turbine.util.search.Search s =
LuceneSearch.newInstance();
s.init ("",""); // Lucene doesn't take passwords
s.setLibrary ("C:\\ApacheCvs\\turbineidx"); // This is on my
local drive
s.doSearch (querystring,1); // Do the work
Enumeration e = s.getResults();
context.put ("results",s.getResults()); // Make results
available
context.put ("file","file");
}
}
// Webmacro template
<font face="verdana,geneva,helvetica">
<b>This is a webmacro test for searching</b><br><br>
<form method="post" action="search.wm">
Enter your query:<br>
<input type="input" name="querystring">
<input type="submit" name="OK" value="OK">
</form>
#if ($results) {
#foreach $result in $results {
$result.get($file)<br>
}
}
</font>
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]