lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Automatic Prefix Query
Date Mon, 26 Sep 2011 15:24:53 GMT
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: uwe@thetaphi.de


> -----Original Message-----
> From: Erick Erickson [mailto:erickerickson@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.szediwy@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-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


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


Mime
View raw message