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: [email protected]
> -----Original Message-----
> From: Erick Erickson [mailto:[email protected]]
> Sent: Monday, September 26, 2011 5:16 PM
> To: [email protected]
> 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
> <[email protected]> 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: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]