lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronnie Kolehmainen <ronnie.kolehmai...@ub.uu.se>
Subject Re: Empty search
Date Thu, 08 Feb 2007 18:32:12 GMT
If you are refering to QueryParser, and if you mean that you want  
Lucene to *find everything* when you actually say *search for  
nothing*, you could easily extend current Queryparser to suit your  
needs:

public class MyQueryParser extends QueryParser
{
     public MyQueryParser(String f, Analyzer a)
     {
         super(f, a);
     }

     public Query parse(String query) throws ParseException
     {
         if (null == query || query.trim().length() == 0)
         {
             return new MatchAllDocsQuery();
         }
         return super.parse(query);
     }
}

Regards,
Ronnie

Quoting "Kainth, Sachin" <Sachin.Kainth@atkinsglobal.com>:

> Is it my imagination or does lucene produce an error if you present it
> with an empty string to search for?
>
>
> This email and any attached files are confidential and copyright   
> protected. If you are not the addressee, any dissemination of this   
> communication is strictly prohibited. Unless otherwise expressly   
> agreed in writing, nothing stated in this communication shall be   
> legally binding.
>
> The ultimate parent company of the Atkins Group is WS Atkins plc.    
> Registered in England No. 1885586.  Registered Office Woodcote   
> Grove, Ashley Road, Epsom, Surrey KT18 5BW.
>
> Consider the environment. Please don't print this e-mail unless you   
> really need to.
>




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