lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Tedone" <mted...@jemos.org>
Subject How I created a Struts search facility
Date Sat, 13 Sep 2003 02:16:30 GMT
Hi , I would like to share with you the solution I chose at the end to
create a search facility for my Struts application. Basically, I followed
the Erik's suggestion to realize something independent from the actual
Struts architectural choice (Tiles, <jsp:include>, and so on), and a couple
of Robert Taylor's email gave me the inspiration. Particularly, I realized
that if I could simulate in someway a request to a Struts Action and write
the response content to a file, well, I had a file ready to be indexed by
Lucene. I had a look at the Java Cookbook, and Darwin gave me the solution:

1) I created a Struts Action which reads all the Actions in the
configuration file which have a parameter forwarding to a jsp page and
creates a collection with those information;

2) I created a Session bean which receives this collection as parameter
(thus, a collection of Action mappings, like
http://myserver/myapp/Login.do), reads the stream for each URL and saves the
content in a file. Here I had a good idea: to name the file with the same
name as the action, only replacing the protocol separator with '@' and the
folder separator with '_' (underscore). The result is a folder with files
containing the real HTML as we would see in the source after visiting a
link, named http@__myserver_myapp_Login.do;

3) I run the real Lucene index, pointing to the folder where all the above
mentioned files are located;

4) I run a query

5) I convert back the returned paths replacing '@' with ':' and '_' with
'/'.

Simple as that: I now have a collection of actions which the user can click
on, which will result in HTML page containing the content the user was
interested in.

This is only the beginning: obviously many optimization may be done: for
instance caching the results, giving the possibility to choose the
separators (both for protocol and folder), organizing the configuration
information in a XML configuration file and so on...

Hope this will help,

Marco




Mime
View raw message