You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2023/12/05 14:01:44 UTC

(solr) branch branch_9x updated: SOLR-17057: JSON Query regression of defType (#2045)

This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 76bb8f2d4dc SOLR-17057: JSON Query regression of defType (#2045)
76bb8f2d4dc is described below

commit 76bb8f2d4dcc4a0a36dc08781d2b3f8e128bc472
Author: David Smiley <ds...@apache.org>
AuthorDate: Mon Dec 4 23:21:32 2023 -0500

    SOLR-17057: JSON Query regression of defType (#2045)
    
    If "query" is specified with a String (not JSON structure), "defType" should parse it.
    Since 9.4, defType was ignored.  Ignoring defType should have been conditional on the query being JSON structured.
---
 solr/CHANGES.txt                                         |  3 +++
 .../java/org/apache/solr/request/json/RequestUtil.java   |  7 +++++--
 .../org/apache/solr/search/json/TestJsonRequest.java     | 16 ++++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7d4c786b070..95dc06df1f8 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -74,6 +74,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.java
index 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.java
index 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/fields
     client.testJQ(
         params(