Skip to main content

How to use your own search engine

1 reply [Last post]
Anonymous

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Roger Brinkley

dell wrote:

> My problem is how to integer
> javahelp and lucene search engine,that can solve the problem of
> chinese language searching .

To use an alternative search engine you will need to implement/extend
the javax.help.search APIs.

Start by extending javax.help.searc.SearchEngine. You only need to
extend the (URL, Hashtable) constructor. Calling super will load "base"
and "param" field. "base" is the base address of the HelpSet. "params"
are the parameters specified in the the search view in the helpset.
You'll have to decide how this information will be relevant to your own
search engine.

Next implement the createQuery abstract method. This is a very simple
class that will return a SearchQuery which you are going to extend from
javax.help.search.SearchQuery. Most likely you'll need to pass the
SearchEngine as a parameter to the SearchQuery constructor otherwise you
will have no access to where the search data resides. At this point
you're done with the extended SearchEngine and you can proceed to
extending javax.help.search.SearchQuery.

In extending javax.help.search.SearchQuery there is little need to
implement the (SearchEngine) constructor. We do in the default but only
for internal reasons. All the listener code works fine on it's own so
you don't have to extend it. You will need to extend the start method.
In the default we check to make sure the search isn't active before
starting the search. Also before you start the search call super.start
so that listener will fire a start search event. In the default we do
the search in a separate thread. This is optional and for your initial
code I would advise against it. You also need to implement isActive and
return a boolean indicating if the search is currently active.

While process your search if you find any items that match create a
javax.help.SearchItem for every item and store the items in a
java.util.Vector. When you have all the events call your implementation
of javax.help.SearchQuery.itemsFound(). Pass a "true" and the vector of
hits. When the search is finished call the searchQuery.fireSearchFinished().

That's it. It isn't rocket science and is fairly easily to implement if
you have java based search engine to work with. The exercise for you to
determine is how to integrate the lucene search engine into this
process. That's beyond the scope of the help that I can provide.

Binky

********************************************************************************

You may leave the list at any time by sending message with no subject and
"SIGNOFF JAVAHELP-INTEREST" in the body to LISTSERV@JAVA.SUN.COM. Archives
are available at http://archives.java.sun.com/archives/javahelp-interest.html.
Submit bug reports at http://java.sun.com/cgi-bin/bugreport.cgi.