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 dboychuck <db...@build.com> on 2013/11/06 05:41:01 UTC

Re: solr 4.3 solrj generating search terms that return no results

I'm having the same issue with solrJ 4.5.1

If I use the escapeQueryChars() function on a string like "a b c" it is
escaping it to "a\+b\+c" which returns 0 results using edismax query parser.
However "a b c" returns results.



--
View this message in context: http://lucene.472066.n3.nabble.com/solr-4-3-solrj-generating-search-terms-that-return-no-results-tp4077137p4099524.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr 4.3 solrj generating search terms that return no results

Posted by dboychuck <db...@build.com>.
Thanks Shawn! That makes sense now. I appreciate the response.



--
View this message in context: http://lucene.472066.n3.nabble.com/solr-4-3-solrj-generating-search-terms-that-return-no-results-tp4077137p4099615.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr 4.3 solrj generating search terms that return no results

Posted by Shawn Heisey <so...@elyograg.org>.
On 11/5/2013 10:22 PM, Shawn Heisey wrote:
> If you do not want the *entire* string treated as a single term for the
> query parser, then you cannot use escapeQueryChars.  You'll need to
> write your own code that is aware of the specific special characters
> that you want to escape.

If your query is already available in pieces rather than just a string
that the user types in, you could do something like the following.  I
don't imagine that this level of object detail would be available, though:

String escTerm1 = ClientUtils.escapeQueryChars(term1);
String escTerm2 = ClientUtils.escapeQueryChars(term2);
String escTerm3 = ClientUtils.escapeQueryChars(term3);
String queryStr = escTerm1 + " " + escTerm2 + " " + escTerm3;
solrQuery.setQuery(queryStr);

Thanks,
Shawn


Re: solr 4.3 solrj generating search terms that return no results

Posted by Shawn Heisey <so...@elyograg.org>.
On 11/5/2013 9:41 PM, dboychuck wrote:
> I'm having the same issue with solrJ 4.5.1
> 
> If I use the escapeQueryChars() function on a string like "a b c" it is
> escaping it to "a\+b\+c" which returns 0 results using edismax query parser.
> However "a b c" returns results.

A space is a special character to the Solr query parser.  It is a term
delimiter.  This means that if you are escaping all special characters,
you have to escape the space.

If you do not want the *entire* string treated as a single term for the
query parser, then you cannot use escapeQueryChars.  You'll need to
write your own code that is aware of the specific special characters
that you want to escape.

Thanks,
Shawn