Perform a search with query containing &

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Perform a search with query containing &

Thierry Collogne
Hello,

I have a field "sitename" that can contain a word with & character, "HR &
O".
Problem is when I do the following query : sitename:HR & O, I get search
results that don't have HR & O in the sitename field.

Is it possible that there is a problem when performing queries containg &?

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Perform a search with query containing &

Erik Hatcher

On Mar 26, 2007, at 7:52 AM, Thierry Collogne wrote:

> Hello,
>
> I have a field "sitename" that can contain a word with & character,  
> "HR &
> O".
> Problem is when I do the following query : sitename:HR & O, I get  
> search
> results that don't have HR & O in the sitename field.
>
> Is it possible that there is a problem when performing queries  
> containg &?

First, on troubleshooting... add &debugQuery=true to your request to  
Solr and see how your query parses.  You'll see output sorta like  
this (example using wt=ruby):

   'rawquerystring'=>'(tang)',
   'querystring'=>'\\(tang\\)',
   'parsedquery'=>'+DisjunctionMaxQuery((text:tang^1.9)~0.01)  
DisjunctionMaxQuery((title_text:tang^2.2 | isbn_text:tang^5.0 |  
author_text:tang^0.5 | call_number_text:tang^5.0)~0.01)',
   'parsedquery_toString'=>'+(text:tang^1.9)~0.01  
(title_text:tang^2.2 | isbn_text:tang^5.0 | author_text:tang^0.5 |  
call_number_text:tang^5.0)~0.01',

Possible solutions for you:

   - sitename:(HR & O)

OR

   - sitename:"HR & O"

Depending on how you're analyzing (or not) that field.

        Erik

Reply | Threaded
Open this post in threaded view
|

Re: Perform a search with query containing &

Thierry Collogne
Thank you. Using sitename:"HR & O" did the trick.

On 26/03/07, Erik Hatcher <[hidden email]> wrote:

>
>
> On Mar 26, 2007, at 7:52 AM, Thierry Collogne wrote:
>
> > Hello,
> >
> > I have a field "sitename" that can contain a word with & character,
> > "HR &
> > O".
> > Problem is when I do the following query : sitename:HR & O, I get
> > search
> > results that don't have HR & O in the sitename field.
> >
> > Is it possible that there is a problem when performing queries
> > containg &?
>
> First, on troubleshooting... add &debugQuery=true to your request to
> Solr and see how your query parses.  You'll see output sorta like
> this (example using wt=ruby):
>
>    'rawquerystring'=>'(tang)',
>    'querystring'=>'\\(tang\\)',
>    'parsedquery'=>'+DisjunctionMaxQuery((text:tang^1.9)~0.01)
> DisjunctionMaxQuery((title_text:tang^2.2 | isbn_text:tang^5.0 |
> author_text:tang^0.5 | call_number_text:tang^5.0)~0.01)',
>    'parsedquery_toString'=>'+(text:tang^1.9)~0.01
> (title_text:tang^2.2 | isbn_text:tang^5.0 | author_text:tang^0.5 |
> call_number_text:tang^5.0)~0.01',
>
> Possible solutions for you:
>
>    - sitename:(HR & O)
>
> OR
>
>    - sitename:"HR & O"
>
> Depending on how you're analyzing (or not) that field.
>
>         Erik
>
>