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 Silvio Hermann <s....@uni-jena.de> on 2013/05/07 20:28:57 UTC

Search identifier fields containing blanks

Hello,

I am about to index identfier fields containing blanks (shelfmarks) eg. G 23/60 12
The field type is set to Solr.string. To get the exact matching hit (the doc with shelfmark mentioned above) the user must quote the search term. Is there a way to omit the quotes?

Best,

Silvio

Re: Search identifier fields containing blanks

Posted by Upayavira <uv...@odoko.co.uk>.

On Wed, May 8, 2013, at 02:07 AM, Chris Hostetter wrote:
> 
> : I am about to index identfier fields containing blanks (shelfmarks) eg.
> G
> : 23/60 12
> : The field type is set to Solr.string. To get the exact matching hit
> (the doc
> : with shelfmark mentioned above) the user must quote the search term. Is
> there
> : a way to omit the quotes?
> 
> whitespace has to be quoted when using the lucene QParser because it's a 
> semanticly significant character that means "end boolean query clause"
> 
> if you want to search for a literal string w/o needing any escaping, use 
> the term QParser...
> 
> 	{!term f=yourFieldName}G 23/60 12
> 
> Of course, if you are putting this in a URL (ie: testing in a browser) it 
> still needs to be URL escaped...
> 
> 	/select?q={!term+f=yourFieldName}G+23/60+12

I'm surprised you didn't offer the improvement (a technique I learned
from you..:-) ):

/select?q={!term f=yourFieldName v=$productCode}&productCode=G 23/60 12

which allows you to present the code as a separate request parameter.

Upayavira

Re: Search identifier fields containing blanks

Posted by Silvio Hermann <s....@uni-jena.de>.
I will give it a go!

thank you

best

Silvio

On 05/08/2013 03:07 AM, Chris Hostetter wrote:
>
> : I am about to index identfier fields containing blanks (shelfmarks) eg. G
> : 23/60 12
> : The field type is set to Solr.string. To get the exact matching hit (the doc
> : with shelfmark mentioned above) the user must quote the search term. Is there
> : a way to omit the quotes?
>
> whitespace has to be quoted when using the lucene QParser because it's a
> semanticly significant character that means "end boolean query clause"
>
> if you want to search for a literal string w/o needing any escaping, use
> the term QParser...
>
> 	{!term f=yourFieldName}G 23/60 12
>
> Of course, if you are putting this in a URL (ie: testing in a browser) it
> still needs to be URL escaped...
>
> 	/select?q={!term+f=yourFieldName}G+23/60+12
>
>
> -Hoss
>

-- 
Silvio Hermann
Friedrich-Schiller-Universität Jena
Thüringer Universitäts- und Landesbibliothek
Bibliotheksplatz 2
07743 Jena
Phone: +49 3641 940019
FAX:   +49 3641 940022

http://www.historische-bestaende.de

Re: Search identifier fields containing blanks

Posted by Jack Krupansky <ja...@basetechnology.com>.
Geez, at this point, why not just escape the space with a backslash instead 
of all that extra cruft:

q=+location:bookshelf myFieldName:G\ 23/60\ 12

or

q=myFieldName:G\ 23/60\ 12 +location:bookshelf

-- Jack Krupansky

-----Original Message----- 
From: Upayavira
Sent: Wednesday, May 08, 2013 6:30 AM
To: solr-user@lucene.apache.org
Subject: Re: Search identifier fields containing blanks

If you're using the latest Solr, then you should be able to do it the
other way around:

q=+location:bookshelf {!term f=myFieldName}G 23/60 12

You might also find the trick I mentioned before useful:

q=+location:bookshelf {!term f=myFieldName v=$productCode}&productCode=G
23/60 12

Upayavira

On Wed, May 8, 2013, at 11:19 AM, Silvio Hermann wrote:
> that worked like a charme, but what must I do if want an additional field
> to match e.g.
>
>
>
> Best,
>
> Silvio
>
>
>
> On 05/08/2013 03:07 AM, Chris Hostetter wrote:
> >
> > : I am about to index identfier fields containing blanks (shelfmarks) 
> > eg. G
> > : 23/60 12
> > : The field type is set to Solr.string. To get the exact matching hit 
> > (the doc
> > : with shelfmark mentioned above) the user must quote the search term. 
> > Is there
> > : a way to omit the quotes?
> >
> > whitespace has to be quoted when using the lucene QParser because it's a
> > semanticly significant character that means "end boolean query clause"
> >
> > if you want to search for a literal string w/o needing any escaping, use
> > the term QParser...
> >
> > {!term f=yourFieldName}G 23/60 12
> >
> > Of course, if you are putting this in a URL (ie: testing in a browser) 
> > it
> > still needs to be URL escaped...
> >
> > /select?q={!term+f=yourFieldName}G+23/60+12
> >
> >
> > -Hoss
> >
>
> -- 
> Silvio Hermann
> Friedrich-Schiller-Universität Jena
> Thüringer Universitäts- und Landesbibliothek
> Bibliotheksplatz 2
> 07743 Jena
> Phone: +49 3641 940019
> FAX:   +49 3641 940022
>
> http://www.historische-bestaende.de 


Re: Search identifier fields containing blanks

Posted by Upayavira <uv...@odoko.co.uk>.
If you're using the latest Solr, then you should be able to do it the
other way around:

q=+location:bookshelf {!term f=myFieldName}G 23/60 12

You might also find the trick I mentioned before useful:

q=+location:bookshelf {!term f=myFieldName v=$productCode}&productCode=G
23/60 12

Upayavira

On Wed, May 8, 2013, at 11:19 AM, Silvio Hermann wrote:
> that worked like a charme, but what must I do if want an additional field
> to match e.g.
> 
> 
> 
> Best,
> 
> Silvio
> 
> 
> 
> On 05/08/2013 03:07 AM, Chris Hostetter wrote:
> >
> > : I am about to index identfier fields containing blanks (shelfmarks) eg. G
> > : 23/60 12
> > : The field type is set to Solr.string. To get the exact matching hit (the doc
> > : with shelfmark mentioned above) the user must quote the search term. Is there
> > : a way to omit the quotes?
> >
> > whitespace has to be quoted when using the lucene QParser because it's a
> > semanticly significant character that means "end boolean query clause"
> >
> > if you want to search for a literal string w/o needing any escaping, use
> > the term QParser...
> >
> > 	{!term f=yourFieldName}G 23/60 12
> >
> > Of course, if you are putting this in a URL (ie: testing in a browser) it
> > still needs to be URL escaped...
> >
> > 	/select?q={!term+f=yourFieldName}G+23/60+12
> >
> >
> > -Hoss
> >
> 
> -- 
> Silvio Hermann
> Friedrich-Schiller-Universität Jena
> Thüringer Universitäts- und Landesbibliothek
> Bibliotheksplatz 2
> 07743 Jena
> Phone: +49 3641 940019
> FAX:   +49 3641 940022
> 
> http://www.historische-bestaende.de

Re: Search identifier fields containing blanks

Posted by Silvio Hermann <s....@uni-jena.de>.
that worked like a charme, but what must I do if want an additional field to match e.g.

{!term f=myFieldName}G 23/60 12 +location:bookshelf

Best,

Silvio



On 05/08/2013 03:07 AM, Chris Hostetter wrote:
>
> : I am about to index identfier fields containing blanks (shelfmarks) eg. G
> : 23/60 12
> : The field type is set to Solr.string. To get the exact matching hit (the doc
> : with shelfmark mentioned above) the user must quote the search term. Is there
> : a way to omit the quotes?
>
> whitespace has to be quoted when using the lucene QParser because it's a
> semanticly significant character that means "end boolean query clause"
>
> if you want to search for a literal string w/o needing any escaping, use
> the term QParser...
>
> 	{!term f=yourFieldName}G 23/60 12
>
> Of course, if you are putting this in a URL (ie: testing in a browser) it
> still needs to be URL escaped...
>
> 	/select?q={!term+f=yourFieldName}G+23/60+12
>
>
> -Hoss
>

-- 
Silvio Hermann
Friedrich-Schiller-Universität Jena
Thüringer Universitäts- und Landesbibliothek
Bibliotheksplatz 2
07743 Jena
Phone: +49 3641 940019
FAX:   +49 3641 940022

http://www.historische-bestaende.de

Re: Search identifier fields containing blanks

Posted by Chris Hostetter <ho...@fucit.org>.
: I am about to index identfier fields containing blanks (shelfmarks) eg. G
: 23/60 12
: The field type is set to Solr.string. To get the exact matching hit (the doc
: with shelfmark mentioned above) the user must quote the search term. Is there
: a way to omit the quotes?

whitespace has to be quoted when using the lucene QParser because it's a 
semanticly significant character that means "end boolean query clause"

if you want to search for a literal string w/o needing any escaping, use 
the term QParser...

	{!term f=yourFieldName}G 23/60 12

Of course, if you are putting this in a URL (ie: testing in a browser) it 
still needs to be URL escaped...

	/select?q={!term+f=yourFieldName}G+23/60+12


-Hoss