You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/06/14 22:42:13 UTC

[GitHub] [solr] madrob commented on a diff in pull request #905: SOLR-16250 Fix LIKE for string fields and multi terms

madrob commented on code in PR #905:
URL: https://github.com/apache/solr/pull/905#discussion_r897379088


##########
solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrFilter.java:
##########
@@ -356,13 +367,16 @@ protected String translateLike(RexNode like) {
       terms = translateLikeTermToSolrSyntax(terms, escapeChar);
 
       if (!terms.startsWith("(") && !terms.startsWith("[") && !terms.startsWith("{")) {
-        terms = escapeWithWildcard(terms);
+        String solrFieldType = solrFieldTypes.get(pair.getKey()).getType();
+        terms = escapeWithWildcard(terms, solrFieldType);
 
         // if terms contains multiple words and one or more wildcard chars, then we need to employ
         // the complexphrase parser
         // but that expects the terms wrapped in double-quotes, not parens
         boolean hasMultipleTerms = terms.split("\\s+").length > 1;
-        if (hasMultipleTerms && (terms.contains("*") || terms.contains("?"))) {
+        if (solrFieldType.equals("text")
+            && hasMultipleTerms

Review Comment:
   Let's think about the order we want these checks, I think there primitive Boolean probably should be first. And then reverse the check to be "text".equals to be better about null handling. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org