a-siuniaev commented on a change in pull request #1122: SOLR-12490 Added 
parsing of json.queries for referring in JSON facets
URL: https://github.com/apache/lucene-solr/pull/1122#discussion_r361398204
 
 

 ##########
 File path: solr/core/src/java/org/apache/solr/request/json/RequestUtil.java
 ##########
 @@ -214,37 +216,22 @@ public static void processParams(SolrRequestHandler 
handler, SolrQueryRequest re
           out = "rows";
         } else if (SORT.equals(key)) {
           out = SORT;
+        } else if ("queries".equals(key)) {
+          for (Map.Entry<String, Object> subEntry : ((Map<String, Object>) 
entry.getValue()).entrySet()) {
+            out = subEntry.getKey();
+            arr = true;
+            isQuery = true;
+            processJsonEntry(newMap, jsonQueryConverter, subEntry, out, 
isQuery, arr);
+          }
+          continue;
         } else if ("params".equals(key) || "facet".equals(key) ) {
           // handled elsewhere
           continue;
         } else {
           throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, 
"Unknown top-level key in JSON request : " + key);
         }
 
-        Object val = entry.getValue();
-
-        if (arr) {
-          String[] existing = newMap.get(out);
-          List lst = val instanceof List ? (List)val : null;
-          int existingSize = existing==null ? 0 : existing.length;
-          int jsonSize = lst==null ? 1 : lst.size();
-          String[] newval = new String[ existingSize + jsonSize ];
-          for (int i=0; i<existingSize; i++) {
-            newval[i] = existing[i];
-          }
-          if (lst != null) {
-            for (int i = 0; i < jsonSize; i++) {
-              Object v = lst.get(i);
-              newval[existingSize + i] = isQuery ? 
jsonQueryConverter.toLocalParams(v, newMap) : v.toString();
-            }
-          } else {
-            newval[newval.length-1] = isQuery ? 
jsonQueryConverter.toLocalParams(val, newMap) : val.toString();
-          }
-          newMap.put(out, newval);
-        } else {
-          newMap.put(out, new String[]{isQuery ? 
jsonQueryConverter.toLocalParams(val, newMap) : val.toString()});
-        }
-
+        processJsonEntry(newMap, jsonQueryConverter, entry, out, isQuery, arr);
 
 Review comment:
   Tried my best to refactor the variables' names.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to