lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joshua O'Madadhain" <>
Subject Re: Query modifier ?
Date Fri, 27 Sep 2002 17:31:16 GMT
On Fri, 27 Sep 2002, Ganael LAPLANCHE wrote:

> Does anyone know how to implement a query modifier with Lucene ? I
> would like to be able to use a dictionary to modify an invalid query
> (just as Google does) and to suggest a new query to the user... This
> isn't really a Lucene-related question, but if someone could help
> me...

The easiest way--or, at least, the method I used--is to do your own query

(1) take the input from the user as a String

(2) do whatever analysis or modifications on it that you like
(e.g., breaking it down into words using a StringTokenizer and checking
each word, by your favorite method, for misspellings)

(3) optionally let user review your modifications (return to (1)) 

(4) create a Term from each word from the modified query

(5) create a Query from your collection of Terms

That's the basic idea.  The details will depend on what kind of query you
want to do, and whether you want to allow the user to specify Boolean
modifiers, term boosts, etc.

It may be possible to use the standard QueryParser to parse the query and
then hack the Query that is returned, but I've never tried it.

Good luck--

Joshua O'Madadhain Per
  Joshua O'Madadhain: Information Scientist, Musician, Philosopher-At-Tall
 It's that moment of dawning comprehension that I live for--Bill Watterson
My opinions are too rational and insightful to be those of any organization.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message