You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Ganael LAPLANCHE <gl...@jouve.fr> on 2002/09/27 16:23:04 UTC

Query modifier ?

Hi !

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...

Thank you,

Gan.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Query modifier ?

Posted by Joshua O'Madadhain <jm...@ics.uci.edu>.
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
parsing: 

(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

 jmadden@ics.uci.edu...Obscurium Per Obscurius...www.ics.uci.edu/~jmadden
  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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>