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 nativecoder <ro...@gmail.com> on 2014/05/14 15:15:30 UTC

Difference between search strings

Can someone please tell me the difference between searching a text in the
following ways

1. q=Exact_Word:"samplestring" -> What does it tell to solr  ?

2. q=samplestring&qf=Exact_Word -> What does it tell to solr  ?

3. q="samplestring"&qf=Exact_Word -> What does it tell to solr  ?
 
I think the first and the third one are the same.  is it correct ? How does
it differ from the second one.

I am trying to understand how enclosing the full term in "" is resolving the
solr specific special character problem? What does it tell to solr  ? e.g If
there is "!" mark in the string solr will identify it as a NOT, "!" is part
of the string. This issue can be corrected if the full string is enclosed in
a "". 






--
View this message in context: http://lucene.472066.n3.nabble.com/Difference-between-search-strings-tp4135571.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Difference between search strings

Posted by Jack Krupansky <ja...@basetechnology.com>.
Inside of quotes you only have to escape quote and backslash.

Add the debugQuery=true parameter to see exactly how Solr processes 
characters and generates queries.

But... in a URL you have to URL-encode URL query parameters:
http://en.wikipedia.org/wiki/Query_string

-- Jack Krupansky

-----Original Message----- 
From: nativecoder
Sent: Wednesday, May 14, 2014 9:15 AM
To: solr-user@lucene.apache.org
Subject: Difference between search strings

Can someone please tell me the difference between searching a text in the
following ways

1. q=Exact_Word:"samplestring" -> What does it tell to solr  ?

2. q=samplestring&qf=Exact_Word -> What does it tell to solr  ?

3. q="samplestring"&qf=Exact_Word -> What does it tell to solr  ?

I think the first and the third one are the same.  is it correct ? How does
it differ from the second one.

I am trying to understand how enclosing the full term in "" is resolving the
solr specific special character problem? What does it tell to solr  ? e.g If
there is "!" mark in the string solr will identify it as a NOT, "!" is part
of the string. This issue can be corrected if the full string is enclosed in
a "".






--
View this message in context: 
http://lucene.472066.n3.nabble.com/Difference-between-search-strings-tp4135571.html
Sent from the Solr - User mailing list archive at Nabble.com. 


Re: Difference between search strings

Posted by Shawn Heisey <so...@elyograg.org>.
On 5/14/2014 7:15 AM, nativecoder wrote:
> Can someone please tell me the difference between searching a text in the
> following ways
> 
> 1. q=Exact_Word:"samplestring" -> What does it tell to solr  ?
> 
> 2. q=samplestring&qf=Exact_Word -> What does it tell to solr  ?
> 
> 3. q="samplestring"&qf=Exact_Word -> What does it tell to solr  ?
>  
> I think the first and the third one are the same.  is it correct ? How does
> it differ from the second one.
> 
> I am trying to understand how enclosing the full term in "" is resolving the
> solr specific special character problem? What does it tell to solr  ? e.g If
> there is "!" mark in the string solr will identify it as a NOT, "!" is part
> of the string. This issue can be corrected if the full string is enclosed in
> a "". 

Quotes surrounding a Solr query turn it into a phrase query.  For fields
where the entire text is a single token, this becomes an exact match.
For tokenized fields, it means that term positions in the index and the
query will be compared -- so the query terms will need to be next to
each other and in that specific order in the indexed data.

Your first and third examples should parse the same, although the third
one only works with the dismax and edismax parsers.  The first one would
work correctly with the standard parser and the edismax parser, but not
the dismax parser.

Quotes will *also* eliminate the need to escape characters that would
normally require backslash escaping.  For single-token fields where
you're doing exact match, quotes will also preserve spaces in the query.
 If you need an actual quote character to be in your query, it needs to
be escaped.

As for the problem you are having with the exclamation point -- the Solr
analaysis page indicates that KeyWordTokenizer does *not* split on
exclamation points.  The only thing I am aware of that uses exclamation
points for splitting is explicit document routing in SolrCloud.  If the
field you are using is the uniqueKey for your index and you are running
SolrCloud, then text before an exclamation point is used for document
routing.  Note:  You should not use a solr.TextField type for your
uniqueKey field, that should be solr.StrField.  If you use
solr.StrField, then you cannot have an analysis chain with a tokenizer,
so any possible confusion about what KeywordTokenizer does would disappear.

Thanks,
Shawn