Apache Solr open-source search software
SOLR-17057: JSON Query regression of defType (#2045)
David Smiley60ff0fa1aacf
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex ed0b55d26d7..b4342b81a65 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -142,6 +142,9 @@ Bug Fixes* SOLR-17090: The v2 "delete alias" API no longer errantly returns a 405 status code (Jason Gerlowski)+* SOLR-17057: JSON Query regression: If "query" is specified with a String (not JSON structure),+ "defType" should parse it. Since 9.4 defType was ignored. (David Smiley)+Dependency Upgrades---------------------* SOLR-17012: Update Apache Hadoop to 3.3.6 and Apache Curator to 5.5.0 (Kevin Risden)diff --git a/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.javaindex d5c46bbb9a1..e6367612951 100644--- a/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java+++ b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java@@ -218,8 +218,11 @@ public class RequestUtil {if ("query".equals(key)) {out = "q";isQuery = true;- String[] queryParsers = {"lucene"};- newMap.put(QueryParsing.DEFTYPE, queryParsers);+ // if the value is not a String, then it'll get converted to a localParams query String.+ // Only the "lucene" query parser can parse it. Ignore anything else that may exist.+ if (!(entry.getValue() instanceof String)) {+ newMap.put(QueryParsing.DEFTYPE, new String[] {"lucene"});+ }} else if ("filter".equals(key)) {out = "fq";arr = true;diff --git a/solr/core/src/test/org/apache/solr/search/json/TestJsonRequest.java b/solr/core/src/test/org/apache/solr/search/json/TestJsonRequest.javaindex fe259dcd473..2f553ff4476 100644--- a/solr/core/src/test/org/apache/solr/search/json/TestJsonRequest.java+++ b/solr/core/src/test/org/apache/solr/search/json/TestJsonRequest.java@@ -224,6 +224,22 @@ public class TestJsonRequest extends SolrTestCaseHS {"response/numFound==2","response/docs==[{id:'4', x:5.5}]");+ // test defType will parse the query string+ client.testJQ(+ params(+ "json",+ "{\n"+ + " 'query': '+all:NY',\n"+ + " 'fields': '*',\n"+ + " 'offset': 0,\n"+ + " 'limit': 10,\n"+ + " 'params': {\n"+ + " 'defType': 'edismax',\n"+ + " 'f.all.qf': 'id cat_s where_s'\n"+ + " }\n"+ + "}"),+ "response/numFound==2");+// test offset/limit/sort/fieldsclient.testJQ(params(