Hi,

You can subclass QueryParser and override newFieldQuery to produce a
PrefixQuery instead of TermQuery - that's all. Here a simple example with an
anonymous inner class:

qp = new QueryParser(...) {
  @Override
  protected Query newTermQuery(Term term) {
    return new PrefixQuery(term);
  }
};

After that this QueryParser instance will produce PrefixQuery for each
token, where it created a TermQuery before (the default impl does "new
TermQuery(term)").

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de


> -----Original Message-----
> From: Erick Erickson [mailto:erickerick...@gmail.com]
> Sent: Monday, September 26, 2011 5:16 PM
> To: java-user@lucene.apache.org
> Subject: Re: Automatic Prefix Query
> 
> You could break the input stream up and construct a BooleanQuery from a
> series of PrefixQuerys, but there's nothing automatic that I know of.
> 
> Best
> Erick
> 
> On Mon, Sep 26, 2011 at 5:30 AM, Michael Szediwy
> <michael.szed...@syslink.ch> wrote:
> > Hi,
> >
> > is it possible to convert a query like "un lis" to "un* lis*"
> > automatically using lucene API?
> > Thanks in advance for your answer.
> >
> > Cheers
> >
> > Michael
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> > For additional commands, e-mail: java-user-h...@lucene.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to