You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2017/07/24 17:27:44 UTC

[4/6] lucene-solr:branch_7_0: SOLR-10494: Make default response format JSON (wt=json), and also indent text responses formats (indent=on) by default

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/solr-ref-guide/src/the-terms-component.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/the-terms-component.adoc b/solr/solr-ref-guide/src/the-terms-component.adoc
index c8b51ca..9f10fb6 100644
--- a/solr/solr-ref-guide/src/the-terms-component.adoc
+++ b/solr/solr-ref-guide/src/the-terms-component.adoc
@@ -260,7 +260,7 @@ Result:
 </response>
 ----
 
-You can use the parameter `omitHeader=true` to omit the response header from the query response, like in this example, which also returns the response in JSON format: `\http://localhost:8983/solr/techproducts/terms?terms.fl=name&terms.prefix=at&indent=true&wt=json&omitHeader=true`
+You can use the parameter `omitHeader=true` to omit the response header from the query response, like in this example, which also returns the response in JSON format: `\http://localhost:8983/solr/techproducts/terms?terms.fl=name&terms.prefix=at&omitHeader=true`
 
 Result:
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/solr-ref-guide/src/transforming-result-documents.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/transforming-result-documents.adoc b/solr/solr-ref-guide/src/transforming-result-documents.adoc
index 754060d..b5b1cff 100644
--- a/solr/solr-ref-guide/src/transforming-result-documents.adoc
+++ b/solr/solr-ref-guide/src/transforming-result-documents.adoc
@@ -97,10 +97,10 @@ Augments each document with an inline explanation of its score exactly like the
 
 [source,plain]
 ----
-q=features:cache&wt=json&fl=id,[explain style=nl]
+q=features:cache&fl=id,[explain style=nl]
 ----
 
-Supported values for "```style```" are "```text```", and "```html```", and "nl" which returns the information as structured data:
+Supported values for `style` are `text`, and `html`, and `nl` which returns the information as structured data:
 
 [source,json]
 ----

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/solr-ref-guide/src/using-javascript.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/using-javascript.adoc b/solr/solr-ref-guide/src/using-javascript.adoc
index d2247fb..62c681f 100644
--- a/solr/solr-ref-guide/src/using-javascript.adoc
+++ b/solr/solr-ref-guide/src/using-javascript.adoc
@@ -22,7 +22,7 @@ Using Solr from JavaScript clients is so straightforward that it deserves a spec
 
 HTTP requests can be sent to Solr using the standard `XMLHttpRequest` mechanism.
 
-Out of the box, Solr can send <<response-writers.adoc#json-response-writer,JavaScript Object Notation (JSON) responses>>, which are easily interpreted in JavaScript. Just add `wt=json` to the request URL to have responses sent as JSON.
+By default, Solr sends <<response-writers.adoc#json-response-writer,JavaScript Object Notation (JSON) responses>>, which are easily interpreted in JavaScript. You don't need to add anything to the request URL to have responses sent as JSON.
 
 For more information and an excellent example, read the SolJSON page on the Solr Wiki:
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/solr-ref-guide/src/using-python.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/using-python.adoc b/solr/solr-ref-guide/src/using-python.adoc
index 84a7b4c..2c51486 100644
--- a/solr/solr-ref-guide/src/using-python.adoc
+++ b/solr/solr-ref-guide/src/using-python.adoc
@@ -58,7 +58,7 @@ JSON is a more robust response format, but you will need to add a Python package
 sudo easy_install simplejson
 ----
 
-Once that is done, making a query is nearly the same as before. However, notice that the wt query parameter is now json, and the response is now digested by `simplejson.load()`.
+Once that is done, making a query is nearly the same as before. However, notice that the wt query parameter is now json (which is also the default if not wt parameter is specified), and the response is now digested by `simplejson.load()`.
 
 [source,python]
 ----

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java
index ab029af..17817bd 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SolrStream.java
@@ -255,6 +255,8 @@ public class SolrStream extends TupleStream {
     if (p != null) {
       ModifiableSolrParams modifiableSolrParams = (ModifiableSolrParams) requestParams;
       modifiableSolrParams.remove("qt");
+      //performance optimization - remove extra whitespace by default when streaming
+      modifiableSolrParams.set("indent", modifiableSolrParams.get("indent", "off"));
     }
 
     String wt = requestParams.get(CommonParams.WT, "json");

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index f034f32..a4d2d9a 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -849,6 +849,13 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
   public static void assertQ(String message, SolrQueryRequest req, String... tests) {
     try {
       String m = (null == message) ? "" : message + " "; // TODO log 'm' !!!
+      //since the default (standard) response format is now JSON
+      //need to explicitly request XML since this class uses XPath
+      ModifiableSolrParams xmlWriterTypeParams = new ModifiableSolrParams(req.getParams());
+      xmlWriterTypeParams.set(CommonParams.WT,"xml");
+      //for tests, let's turn indention off so we don't have to handle extraneous spaces
+      xmlWriterTypeParams.set("indent", xmlWriterTypeParams.get("indent", "off"));
+      req.setParams(xmlWriterTypeParams);
       String response = h.query(req);
 
       if (req.getParams().getBool("facet", false)) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/test-framework/src/java/org/apache/solr/util/RestTestBase.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/util/RestTestBase.java b/solr/test-framework/src/java/org/apache/solr/util/RestTestBase.java
index b6209bf..12cad01 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/RestTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/RestTestBase.java
@@ -498,7 +498,7 @@ abstract public class RestTestBase extends SolrJettyTestBase {
    *
    * The passed-in valueToSet should NOT be URL encoded, as it will be URL encoded by this method.
    *
-   * @param query The query portion of a request URL, e.g. "wt=json&indent=on&fl=id,_version_"
+   * @param query The query portion of a request URL, e.g. "wt=xml&indent=off&fl=id,_version_"
    * @param paramToSet The parameter name to insure the presence of in the returned request 
    * @param valueToSet The parameter value to insure in the returned request
    * @return The query with the given param set to the given value 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java
index 11e28a6..2769d9b 100644
--- a/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java
+++ b/solr/test-framework/src/java/org/apache/solr/util/RestTestHarness.java
@@ -97,7 +97,7 @@ public class RestTestHarness extends BaseTestHarness implements Closeable {
 
   /**
    * Processes a "query" using a URL path (with no context path) + optional query params,
-   * e.g. "/schema/fields?indent=on"
+   * e.g. "/schema/fields?indent=off"
    *
    * @param request the URL path and optional query params
    * @return The response to the query
@@ -181,10 +181,10 @@ public class RestTestHarness extends BaseTestHarness implements Closeable {
   @Override
   public void reload() throws Exception {
     String coreName = (String)evaluateXPath
-        (adminQuery("/admin/cores?action=STATUS"),
+        (adminQuery("/admin/cores?wt=xml&action=STATUS"),
          "//lst[@name='status']/lst[1]/str[@name='name']",
          XPathConstants.STRING);
-    String xml = checkAdminResponseStatus("/admin/cores?action=RELOAD&core=" + coreName, "0");
+    String xml = checkAdminResponseStatus("/admin/cores?wt=xml&action=RELOAD&core=" + coreName, "0");
     if (null != xml) {
       throw new RuntimeException("RELOAD failed:\n" + xml);
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/webapp/web/js/angular/controllers/query.js
----------------------------------------------------------------------
diff --git a/solr/webapp/web/js/angular/controllers/query.js b/solr/webapp/web/js/angular/controllers/query.js
index 3a44cbd..63f0830 100644
--- a/solr/webapp/web/js/angular/controllers/query.js
+++ b/solr/webapp/web/js/angular/controllers/query.js
@@ -20,7 +20,7 @@ solrAdminApp.controller('QueryController',
     $scope.resetMenu("query", Constants.IS_COLLECTION_PAGE);
 
     // @todo read URL parameters into scope
-    $scope.query = {wt: 'json', q:'*:*', indent:'on'};
+    $scope.query = {q:'*:*'};
     $scope.filters = [{fq:""}];
     $scope.dismax = {defType: "dismax"};
     $scope.edismax = {defType: "edismax", stopwords: true, lowercaseOperators: false};
@@ -87,6 +87,9 @@ solrAdminApp.controller('QueryController',
       var url = Query.url(params);
       Query.query(params, function(data) {
         $scope.lang = $scope.query.wt;
+        if ($scope.lang == undefined || $scope.lang == '') {
+          $scope.lang = "json";
+        }
         $scope.response = data;
         // Use relative URL to make it also work through proxies that may have a different host/port/context
         $scope.url = url;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477c2188/solr/webapp/web/partials/query.html
----------------------------------------------------------------------
diff --git a/solr/webapp/web/partials/query.html b/solr/webapp/web/partials/query.html
index d68d236..2a77355 100644
--- a/solr/webapp/web/partials/query.html
+++ b/solr/webapp/web/partials/query.html
@@ -78,6 +78,7 @@ limitations under the License.
           <a rel="help">wt</a>
         </label>
         <select name="wt" ng-model="query.wt" id="wt" title="The writer type (response format).">
+          <option ng-selected="selected" value=''>------</option>
           <option>json</option>
           <option>xml</option>
           <option>python</option>
@@ -86,9 +87,9 @@ limitations under the License.
           <option>csv</option>
         </select>
 
-        <label for="indent" class="checkbox" title="Indent results.">
-          <input type="checkbox" ng-model="query.indent" name="indent" id="indent" title="Indent results." ng-true-value="'on'" ng-false-value="''">
-          indent
+        <label for="indent off" class="checkbox" title="Do not indent results.">
+          <input type="checkbox" ng-model="query.indent" name="indent" id="indent" title="Do not indent results." ng-true-value="'off'" ng-false-value="''">
+          indent off
         </label>
 
         <label for="debugQuery" class="checkbox" title="Show timing and diagnostics.">