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 "Kainth, Sachin" <Sa...@atkinsglobal.com> on 2007/02/08 18:46:12 UTC

Empty search

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. 

RE: Empty search

Posted by "Kainth, Sachin" <Sa...@atkinsglobal.com>.
You are right I didn't think about it at all to be honest. 

-----Original Message-----
From: karl wettin [mailto:karl.wettin@gmail.com] 
Sent: 09 February 2007 10:46
To: java-user@lucene.apache.org
Subject: Re: Empty search


9 feb 2007 kl. 11.34 skrev Kainth, Sachin:

> Yep it is the queryparser that I'm referring to.  Just sounds odd to 
> me.
> An empty string search should be handled properly I think.  It should 
> simply  to nothing.

I did not look any closer at this than reading you post, but what about
if you made sure that no empty strings is passed to the QueryParser?

I'd expect an exception if I passed a string to a parser that did not
match the grammar defined by it. And the QueryParser is a parser, not a
searcher. It apptempts to parse a query from the string value. If it was
to do nothing then it would return null. And that would just cause
another exception.


--
karl

>
> -----Original Message-----
> From: karl wettin [mailto:karl.wettin@gmail.com]
> Sent: 08 February 2007 18:05
> To: java-user@lucene.apache.org
> Subject: Re: Empty search
>
>
> 8 feb 2007 kl. 18.46 skrev Kainth, Sachin:
>
>> Is it my imagination or does lucene produce an error if you present 
>> it
>
>> with an empty string to search for?
>
> I presume you are referring to the QueryParser? It sounds about right 
> that it would throw an exception at some point if you supplied it an 
> empty input.
>
>
> --
> karl
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
> This message has been scanned for viruses by MailControl - (see
> http://bluepages.wsatkins.co.uk/?4318150)
>
>
> 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
>


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


Re: Empty search

Posted by karl wettin <ka...@gmail.com>.
9 feb 2007 kl. 11.34 skrev Kainth, Sachin:

> Yep it is the queryparser that I'm referring to.  Just sounds odd  
> to me.
> An empty string search should be handled properly I think.  It should
> simply  to nothing.

I did not look any closer at this than reading you post, but what  
about if you made sure that no empty strings is passed to the  
QueryParser?

I'd expect an exception if I passed a string to a parser that did not  
match the grammar defined by it. And the QueryParser is a parser, not  
a searcher. It apptempts to parse a query from the string value. If  
it was to do nothing then it would return null. And that would just  
cause another exception.


-- 
karl

>
> -----Original Message-----
> From: karl wettin [mailto:karl.wettin@gmail.com]
> Sent: 08 February 2007 18:05
> To: java-user@lucene.apache.org
> Subject: Re: Empty search
>
>
> 8 feb 2007 kl. 18.46 skrev Kainth, Sachin:
>
>> Is it my imagination or does lucene produce an error if you  
>> present it
>
>> with an empty string to search for?
>
> I presume you are referring to the QueryParser? It sounds about right
> that it would throw an exception at some point if you supplied it an
> empty input.
>
>
> --
> karl
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
> This message has been scanned for viruses by MailControl - (see
> http://bluepages.wsatkins.co.uk/?4318150)
>
>
> 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
>


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


RE: Empty search

Posted by "Kainth, Sachin" <Sa...@atkinsglobal.com>.
Yep it is the queryparser that I'm referring to.  Just sounds odd to me.
An empty string search should be handled properly I think.  It should
simply  to nothing. 

-----Original Message-----
From: karl wettin [mailto:karl.wettin@gmail.com] 
Sent: 08 February 2007 18:05
To: java-user@lucene.apache.org
Subject: Re: Empty search


8 feb 2007 kl. 18.46 skrev Kainth, Sachin:

> Is it my imagination or does lucene produce an error if you present it

> with an empty string to search for?

I presume you are referring to the QueryParser? It sounds about right
that it would throw an exception at some point if you supplied it an
empty input.


--
karl



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



This message has been scanned for viruses by MailControl - (see
http://bluepages.wsatkins.co.uk/?4318150)


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


Re: Empty search

Posted by karl wettin <ka...@gmail.com>.
8 feb 2007 kl. 18.46 skrev Kainth, Sachin:

> Is it my imagination or does lucene produce an error if you present it
> with an empty string to search for?

I presume you are referring to the QueryParser? It sounds about right  
that it would throw an exception at some point if you supplied it an  
empty input.


-- 
karl



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


Re: Empty search

Posted by Ronnie Kolehmainen <ro...@ub.uu.se>.
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" <Sa...@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