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 Burak <bu...@gmail.com> on 2011/01/09 23:08:22 UTC

Solr question regarding handlers and escaping

I have a couple of questions regarding Solr usage:

   1. Certain requests can be sent to different paths (handlers?). For
      example, the MoreLikeThis component can being sent to either
      /select or /mlt.

I have found these two links in the Solr wiki:

http://localhost:8983/solr/mlt?q=id:UTF8TEST&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&mlt.match.include=false
<http://localhost:8983/solr/mlt?q=id:UTF8TEST&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&mlt.match.include=false>

http://localhost:8983/solr/select?q=apache&mlt=true&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&fl=id,score
<http://localhost:8983/solr/select?q=apache&mlt=true&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&fl=id,score>

What is the reasoning behind this setup? If I decide to send my
MoreLikeThis requests to /mlt does this mean I can not utilize any
/select specific calls - if there is even such a thing - such as facets
- ? If not, can a /select path can be configured to handle all requests
from Spellcheck to Clustering?

   1. How do you escape double character special strings (&&, ||) in Lucene?

http://lucene.apache.org/java/2_9_1/queryparsersyntax.html#Escaping+Special+Characters

Do I escape the first character only (\&&) or do I escape both? And when
do I need to escape them? A couple of tests that I performed on the
example server provided in the Solr package were inconclusive:

http://localhost:8983/solr/select/?q=manu:%22apple%20%26%26%22%20AND%20manu:%22computer%22

Still returns results,


Re: Solr question regarding handlers and escaping

Posted by Burak <bu...@gmail.com>.
On 01/09/2011 04:05 PM, Ahmet Arslan wrote:
>> ���1. Certain requests can be sent to
>> different paths (handlers?). For
>> � � � example, the MoreLikeThis component
>> can being sent to either
>> � � � /select or /mlt.
>>
>> I have found these two links in the Solr wiki:
>>
>> http://localhost:8983/solr/mlt?q=id:UTF8TEST&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&mlt.match.include=false
>> <http://localhost:8983/solr/mlt?q=id:UTF8TEST&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&mlt.match.include=false>
>>
>> http://localhost:8983/solr/select?q=apache&mlt=true&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&fl=id,score
>> <http://localhost:8983/solr/select?q=apache&mlt=true&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&fl=id,score>
>>
>> What is the reasoning behind this setup? If I decide to
>> send my
>> MoreLikeThis requests to /mlt does this mean I can not
>> utilize any
>> /select specific calls - if there is even such a thing -
>> such as facets
>> - ? If not, can a /select path can be configured to handle
>> all requests
>> from Spellcheck to Clustering?
>>     
> The url with /mlt requires MoreLikeThisHandler registered in solrconfig.xml
>
> <requestHandler name="/mlt" class="org.apache.solr.handler.MoreLikeThisHandler">
>
> You can give a name to SearchHandler/RequestHandler registered in solrconfig. You can always access them with qt parameter.
>
> Additionally if the name starts with / then you can directly use that in URL. so /mtl and /select?qt=/mlt is the same.
>   
Ah, this sentence clears a lot of my confusion.
> MLT has both SearchComponent and RequestHandler so it is a little bit confusing. Same SearchHandler/RequestHandler can be registered and used with different names. For example see dismax, partitioned and standard in example solrconfig.xml. Standard has default="true", you can call others with qt parameter.
>   
I now understand how it works. However, I still don't get the reasoning
behind this setup. Maybe performance (excluding unnecessary
components?). It also makes writing a client API problematic (which I am
doing right now).
> Yes, /select path can be configured to handle all requests from Spellcheck to Clustering. They are all SearchComponents. These are the default components that are available by default:
>
> <arr name="components">
>       <str>query</str>
>       <str>facet</str>
>       <str>mlt</str>
>       <str>highlight</str>
>       <str>stats</str>
>       <str>debug</str>
>     </arr>
>
> You can add new ones like Spellcheck, Clustering, TermsComponent etc.
>
>   
>> ���1. How do you escape double character
>> special strings (&&, ||) in Lucene?
>>
>> http://lucene.apache.org/java/2_9_1/queryparsersyntax.html#Escaping+Special+Characters
>>
>> Do I escape the first character only (\&&) or do I
>> escape both? And when
>> do I need to escape them? A couple of tests that I
>> performed on the
>> example server provided in the Solr package were
>> inconclusive:
>>     
> I think both. \&\& 
> QueryParser has a static String escape(String s) method for that.
> If you want to query those special characters you need to escape. But alternatively there are some special query parsers that do not need escaping. e.g. raw and field.
>
>
>       
>   
Thanks for the help.


Re: Solr question regarding handlers and escaping

Posted by Ahmet Arslan <io...@yahoo.com>.
>    1. Certain requests can be sent to
> different paths (handlers?). For
>       example, the MoreLikeThis component
> can being sent to either
>       /select or /mlt.
> 
> I have found these two links in the Solr wiki:
> 
> http://localhost:8983/solr/mlt?q=id:UTF8TEST&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&mlt.match.include=false
> <http://localhost:8983/solr/mlt?q=id:UTF8TEST&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&mlt.match.include=false>
> 
> http://localhost:8983/solr/select?q=apache&mlt=true&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&fl=id,score
> <http://localhost:8983/solr/select?q=apache&mlt=true&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&fl=id,score>
> 
> What is the reasoning behind this setup? If I decide to
> send my
> MoreLikeThis requests to /mlt does this mean I can not
> utilize any
> /select specific calls - if there is even such a thing -
> such as facets
> - ? If not, can a /select path can be configured to handle
> all requests
> from Spellcheck to Clustering?

The url with /mlt requires MoreLikeThisHandler registered in solrconfig.xml

<requestHandler name="/mlt" class="org.apache.solr.handler.MoreLikeThisHandler">

You can give a name to SearchHandler/RequestHandler registered in solrconfig. You can always access them with qt parameter.

Additionally if the name starts with / then you can directly use that in URL. so /mtl and /select?qt=/mlt is the same.

MLT has both SearchComponent and RequestHandler so it is a little bit confusing. Same SearchHandler/RequestHandler can be registered and used with different names. For example see dismax, partitioned and standard in example solrconfig.xml. Standard has default="true", you can call others with qt parameter.

Yes, /select path can be configured to handle all requests from Spellcheck to Clustering. They are all SearchComponents. These are the default components that are available by default:

<arr name="components">
      <str>query</str>
      <str>facet</str>
      <str>mlt</str>
      <str>highlight</str>
      <str>stats</str>
      <str>debug</str>
    </arr>

You can add new ones like Spellcheck, Clustering, TermsComponent etc.

> 
>    1. How do you escape double character
> special strings (&&, ||) in Lucene?
> 
> http://lucene.apache.org/java/2_9_1/queryparsersyntax.html#Escaping+Special+Characters
> 
> Do I escape the first character only (\&&) or do I
> escape both? And when
> do I need to escape them? A couple of tests that I
> performed on the
> example server provided in the Solr package were
> inconclusive:

I think both. \&\& 
QueryParser has a static String escape(String s) method for that.
If you want to query those special characters you need to escape. But alternatively there are some special query parsers that do not need escaping. e.g. raw and field.