You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Dan A. Dickey" <da...@savvis.net> on 2009/10/23 16:12:48 UTC

help with how to search using spaces in the query for string fields...

I'm having a problem with figuring out how to search for things
that have spaces (just a single space character) in them.
For example, I have a field named "FileName" and it is of type string.
I've indexed a couple of documents, that have field FileName
equal to "File 10 10AM" and another that has FileName "File 11 11AM".
In my search query, I'm trying "Filename:(File 1*)" and I'd like to it
return both documents.  It return none.
If I search for "Filename:(File*)" I get both of them and everything else.
I've tried lots of different ways to form the query, but the only thing
that returns any documents is the "FileName:(File*)" form.  Anything
else with an actual space in it fails.
This has got to be another simple thing that I'm missing, but haven't
figured it out yet nor stumbled upon the correct search query.
Help please!  The above scenario is an example, but I am using
the string field type.
	-Dan

-- 
Dan A. Dickey | Senior Software Engineer

Savvis
10900 Hampshire Ave. S., Bloomington, MN  55438
Office: 952.852.4803 | Fax: 952.852.4951
E-mail: dan.dickey@savvis.net

Re: help with how to search using spaces in the query for string fields...

Posted by "Dan A. Dickey" <da...@savvis.net>.
On Friday 23 October 2009 09:36:02 am AHMET ARSLAN wrote:
> 
> --- On Fri, 10/23/09, Dan A. Dickey <da...@savvis.net> wrote:
> 
> > From: Dan A. Dickey <da...@savvis.net>
> > Subject: help with how to search using spaces in the query for string fields...
> > To: solr-user@lucene.apache.org
> > Date: Friday, October 23, 2009, 5:12 PM
> > I'm having a problem with figuring
> > out how to search for things
> > that have spaces (just a single space character) in them.
> > For example, I have a field named "FileName" and it is of
> > type string.
> > I've indexed a couple of documents, that have field
> > FileName
> > equal to "File 10 10AM" and another that has FileName "File
> > 11 11AM".
> > In my search query, I'm trying "Filename:(File 1*)" and I'd
> > like to it
> > return both documents.  It return none.
> > If I search for "Filename:(File*)" I get both of them and
> > everything else.
> > I've tried lots of different ways to form the query, but
> > the only thing
> > that returns any documents is the "FileName:(File*)"
> > form.  Anything
> > else with an actual space in it fails.
> > This has got to be another simple thing that I'm missing,
> > but haven't
> > figured it out yet nor stumbled upon the correct search
> > query.
> > Help please!  The above scenario is an example, but I
> > am using
> > the string field type.
> >     -Dan
> 
> You need to escape space. Try this one :  Filename:(File\ 1*)

Ahmet,
When I first saw your suggestion - I thought - I tried that.  It didn't work.
I went and did it again - it works beautifully!  Evidently, I *did not* try it.
You're a genius!  Thank you again!
	-Dan 

-- 
Dan A. Dickey | Senior Software Engineer

Savvis
10900 Hampshire Ave. S., Bloomington, MN  55438
Office: 952.852.4803 | Fax: 952.852.4951
E-mail: dan.dickey@savvis.net

Re: help with how to search using spaces in the query for string fields...

Posted by AHMET ARSLAN <io...@yahoo.com>.

--- On Fri, 10/23/09, Dan A. Dickey <da...@savvis.net> wrote:

> From: Dan A. Dickey <da...@savvis.net>
> Subject: help with how to search using spaces in the query for string fields...
> To: solr-user@lucene.apache.org
> Date: Friday, October 23, 2009, 5:12 PM
> I'm having a problem with figuring
> out how to search for things
> that have spaces (just a single space character) in them.
> For example, I have a field named "FileName" and it is of
> type string.
> I've indexed a couple of documents, that have field
> FileName
> equal to "File 10 10AM" and another that has FileName "File
> 11 11AM".
> In my search query, I'm trying "Filename:(File 1*)" and I'd
> like to it
> return both documents.  It return none.
> If I search for "Filename:(File*)" I get both of them and
> everything else.
> I've tried lots of different ways to form the query, but
> the only thing
> that returns any documents is the "FileName:(File*)"
> form.  Anything
> else with an actual space in it fails.
> This has got to be another simple thing that I'm missing,
> but haven't
> figured it out yet nor stumbled upon the correct search
> query.
> Help please!  The above scenario is an example, but I
> am using
> the string field type.
>     -Dan

You need to escape space. Try this one :  Filename:(File\ 1*)