From 6a59253ec34e9e08d6b2306b51c81199d3f3d828 Mon Sep 17 00:00:00 2001 From: Chris Hostetter Date: Mon, 24 Jul 2017 08:42:02 -0700 Subject: [PATCH] SOLR-10494: Make default response format JSON (wt=json), and also indent text responses formats (indent=on) by default --- solr/CHANGES.txt | 8 + .../TestHierarchicalDocBuilder.java | 6 +- solr/contrib/ltr/example/README.md | 2 +- .../java/org/apache/solr/core/SolrCore.java | 2 +- .../solr/response/TextResponseWriter.java | 2 +- .../solr/servlet/DirectSolrConnection.java | 1 + .../configsets/_default/conf/solrconfig.xml | 7 +- .../org/apache/solr/TestCrossCoreJoin.java | 9 +- .../solr/cloud/BasicDistributedZk2Test.java | 1 + .../solr/cloud/SolrCloudExampleTest.java | 2 +- .../apache/solr/cloud/TestConfigSetsAPI.java | 6 +- .../org/apache/solr/cloud/TestCryptoKeys.java | 28 +-- .../solr/core/TestConfigSetImmutable.java | 4 +- .../apache/solr/core/TestCustomStream.java | 4 +- .../apache/solr/core/TestDynamicLoading.java | 38 ++--- .../solr/core/TestSolrConfigHandler.java | 160 +++++++++--------- .../solr/handler/CheckBackupStatus.java | 2 +- .../apache/solr/handler/TestConfigReload.java | 2 +- .../handler/TestReplicationHandlerBackup.java | 4 +- .../apache/solr/handler/TestReqParamsAPI.java | 44 ++--- .../apache/solr/handler/TestRestoreCore.java | 2 +- .../apache/solr/handler/TestSQLHandler.java | 5 +- .../handler/TestSolrConfigHandlerCloud.java | 40 ++--- .../TestSolrConfigHandlerConcurrent.java | 4 +- .../apache/solr/response/JSONWriterTest.java | 4 +- .../solr/response/TestRawResponseWriter.java | 11 +- .../solr/rest/schema/TestBulkSchemaAPI.java | 58 +++---- .../TestCopyFieldCollectionResource.java | 12 +- .../schema/TestFieldCollectionResource.java | 24 +-- .../rest/schema/TestFieldTypeResource.java | 14 +- .../rest/schema/TestSchemaNameResource.java | 2 +- .../solr/rest/schema/TestSchemaResource.java | 2 +- .../schema/TestSchemaSimilarityResource.java | 2 +- .../solr/schema/TestBulkSchemaConcurrent.java | 6 +- .../schema/TestUseDocValuesAsStored2.java | 8 +- .../solr/search/TestHashQParserPlugin.java | 7 + .../security/BasicAuthIntegrationTest.java | 2 +- .../solr/servlet/HttpSolrCallGetCoreTest.java | 2 +- .../processor/TestNamedUpdateProcessors.java | 8 +- .../example-DIH/solr/atom/conf/solrconfig.xml | 3 + .../example-DIH/solr/db/conf/solrconfig.xml | 3 + .../example-DIH/solr/mail/conf/solrconfig.xml | 3 + .../example-DIH/solr/solr/conf/solrconfig.xml | 3 + .../example-DIH/solr/tika/conf/solrconfig.xml | 3 + solr/example/exampledocs/test_utf8.sh | 4 +- solr/example/files/conf/solrconfig.xml | 7 +- .../configsets/_default/conf/solrconfig.xml | 7 +- .../conf/solrconfig.xml | 6 + solr/site/quickstart.mdtext | 51 +++--- solr/solr-ref-guide/src/collections-api.adoc | 6 +- .../src/common-query-parameters.adoc | 2 + solr/solr-ref-guide/src/config-api.adoc | 12 +- solr/solr-ref-guide/src/configsets-api.adoc | 2 +- .../src/configuring-logging.adoc | 2 +- .../cross-data-center-replication-cdcr.adoc | 2 +- solr/solr-ref-guide/src/enabling-ssl.adoc | 4 +- solr/solr-ref-guide/src/faceting.adoc | 5 +- solr/solr-ref-guide/src/highlighting.adoc | 2 +- .../src/mbean-request-handler.adoc | 6 +- .../solr-ref-guide/src/metrics-reporting.adoc | 6 +- solr/solr-ref-guide/src/ping.adoc | 2 +- solr/solr-ref-guide/src/query-screen.adoc | 4 +- solr/solr-ref-guide/src/realtime-get.adoc | 2 - .../src/request-parameters-api.adoc | 2 - solr/solr-ref-guide/src/response-writers.adoc | 132 +++++++-------- solr/solr-ref-guide/src/result-grouping.adoc | 12 +- solr/solr-ref-guide/src/schema-api.adoc | 18 +- solr/solr-ref-guide/src/suggester.adoc | 7 +- .../src/the-terms-component.adoc | 2 +- .../src/transforming-result-documents.adoc | 4 +- solr/solr-ref-guide/src/using-javascript.adoc | 2 +- solr/solr-ref-guide/src/using-python.adoc | 2 +- .../client/solrj/io/stream/SolrStream.java | 2 + .../java/org/apache/solr/SolrTestCaseJ4.java | 7 + .../org/apache/solr/util/RestTestBase.java | 2 +- .../org/apache/solr/util/RestTestHarness.java | 6 +- .../web/js/angular/controllers/query.js | 5 +- solr/webapp/web/partials/query.html | 7 +- 78 files changed, 487 insertions(+), 415 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 9964e361ad3..b123477c92e 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -126,6 +126,11 @@ Jetty 9.3.14.v20161028 Upgrading from Solr 6.x ---------------------- +* The default response type is now JSON ("wt=json") instead of XML, and line indentation is now on by default + ("indent=on"). If you expect the responses to your queries to be returned in the previous format (XML + format, no indentation), you must now you must now explicitly pass in "wt=xml" and "indent=off" as query + parameters, or configure them as defaults on your request handlers. See SOLR-10494 for more details. + * the cluster property 'legacyCloud' is set to false from 7.0. This means 'zookeeper is the truth' by default. If an entry for a replica does not exist in the state.json, that replica cannot get registered. This may affect users who use that feature where they bring up replicas and they are @@ -539,6 +544,9 @@ Other Changes * SOLR-11119: Switch from Trie to Points field types in the .system collection schema. (Steve Rowe) +* SOLR-10494: Make default response format JSON (wt=json), and also indent text responses formats + (indent=on) by default (Trey Grainger & Cassandra Targett via hossman) + ================== 6.7.0 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. diff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestHierarchicalDocBuilder.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestHierarchicalDocBuilder.java index 086d7beed58..103d0dc0e31 100644 --- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestHierarchicalDocBuilder.java +++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestHierarchicalDocBuilder.java @@ -160,9 +160,9 @@ public class TestHierarchicalDocBuilder extends AbstractDataImportHandlerTestCas int totalDocsNum = parentsNum + childrenNum + grandChildrenNum; String resp = runFullImport(THREE_LEVEL_HIERARCHY_CONFIG); - String xpath = "//arr[@name='documents']/lst/arr[@name='id' and .='"+parentId1+"']/../"+ - "arr[@name='_childDocuments_']/lst/arr[@name='id' and .='"+childId+"']/../"+ - "arr[@name='_childDocuments_']/lst/arr[@name='id' and .='"+grandChildrenIds.get(0)+"']"; + String xpath = "//arr[@name='documents']/lst[arr[@name='id']/str='"+parentId1+"']/"+ + "arr[@name='_childDocuments_']/lst[arr[@name='id']/str='"+childId+"']/"+ + "arr[@name='_childDocuments_']/lst[arr[@name='id']/str='"+grandChildrenIds.get(0)+"']"; String results = TestHarness.validateXPath(resp, xpath); assertTrue("Debug documents does not contain child documents\n"+resp+"\n"+ xpath+ diff --git a/solr/contrib/ltr/example/README.md b/solr/contrib/ltr/example/README.md index 77e582aab97..06a47890f5d 100644 --- a/solr/contrib/ltr/example/README.md +++ b/solr/contrib/ltr/example/README.md @@ -29,7 +29,7 @@ Please refer to the Solr Reference Guide's section on [Learning To Rank](https:/ 4. Search and rerank the results using the trained model ``` -http://localhost:8983/solr/techproducts/query?indent=on&q=test&wt=json&rq={!ltr%20model=exampleModel%20reRankDocs=25%20efi.user_query=%27test%27}&fl=price,score,name +http://localhost:8983/solr/techproducts/query?q=test&rq={!ltr%20model=exampleModel%20reRankDocs=25%20efi.user_query=%27test%27}&fl=price,score,name ``` # Assemble training data diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index 53198816fa3..cc6a9c28e43 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -2565,8 +2565,8 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab static{ HashMap m= new HashMap<>(15, 1); m.put("xml", new XMLResponseWriter()); - m.put("standard", m.get("xml")); m.put(CommonParams.JSON, new JSONResponseWriter()); + m.put("standard", m.get(CommonParams.JSON)); m.put("geojson", new GeoJSONResponseWriter()); m.put("graphml", new GraphMLResponseWriter()); m.put("python", new PythonResponseWriter()); diff --git a/solr/core/src/java/org/apache/solr/response/TextResponseWriter.java b/solr/core/src/java/org/apache/solr/response/TextResponseWriter.java index 261daeedf71..4d052ae4943 100644 --- a/solr/core/src/java/org/apache/solr/response/TextResponseWriter.java +++ b/solr/core/src/java/org/apache/solr/response/TextResponseWriter.java @@ -84,7 +84,7 @@ public abstract class TextResponseWriter implements PushWriter { this.req = req; this.rsp = rsp; String indent = req.getParams().get("indent"); - if (indent != null && !"".equals(indent) && !"off".equals(indent)) { + if (null == indent || !("off".equals(indent) || "false".equals(indent))){ doIndent=true; } returnFields = rsp.getReturnFields(); diff --git a/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java b/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java index 2d3d68328c9..7fecd296787 100644 --- a/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java +++ b/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java @@ -63,6 +63,7 @@ public class DirectSolrConnection * For example: * * String json = solr.request( "/select?qt=dismax&wt=json&q=...", null ); + * String xml = solr.request( "/select?qt=dismax&wt=xml&q=...", null ); * String xml = solr.request( "/update", "<add><doc><field ..." ); */ public String request( String pathAndParams, String body ) throws Exception diff --git a/solr/core/src/test-files/solr/configsets/_default/conf/solrconfig.xml b/solr/core/src/test-files/solr/configsets/_default/conf/solrconfig.xml index c18febb0e2e..3b110820705 100644 --- a/solr/core/src/test-files/solr/configsets/_default/conf/solrconfig.xml +++ b/solr/core/src/test-files/solr/configsets/_default/conf/solrconfig.xml @@ -716,7 +716,12 @@ explicit 10 - + + diff --git a/solr/example/example-DIH/solr/db/conf/solrconfig.xml b/solr/example/example-DIH/solr/db/conf/solrconfig.xml index aae723d9b97..6b53a95d8c9 100644 --- a/solr/example/example-DIH/solr/db/conf/solrconfig.xml +++ b/solr/example/example-DIH/solr/db/conf/solrconfig.xml @@ -713,6 +713,9 @@ explicit 10 text + diff --git a/solr/example/exampledocs/test_utf8.sh b/solr/example/exampledocs/test_utf8.sh index b750bdeb40e..9032e12ffe3 100755 --- a/solr/example/exampledocs/test_utf8.sh +++ b/solr/example/exampledocs/test_utf8.sh @@ -82,8 +82,8 @@ else echo "ERROR: HTTP POST + URL params is not accepting UTF-8 beyond the basic multilingual plane" fi -#curl "$SOLR_URL/select?q=$UTF8_Q&echoParams=explicit&wt=json" 2> /dev/null | od -tx1 -w1000 | sed 's/ //g' | grep 'f4808198' > /dev/null 2>&1 -curl "$SOLR_URL/select?q=$UTF8_Q&echoParams=explicit&wt=json" 2> /dev/null | grep "$CHAR" > /dev/null 2>&1 +#curl "$SOLR_URL/select?q=$UTF8_Q&echoParams=explicit" 2> /dev/null | od -tx1 -w1000 | sed 's/ //g' | grep 'f4808198' > /dev/null 2>&1 +curl "$SOLR_URL/select?q=$UTF8_Q&echoParams=explicit" 2> /dev/null | grep "$CHAR" > /dev/null 2>&1 if [ $? = 0 ]; then echo "Response correctly returns UTF-8 beyond the basic multilingual plane" else diff --git a/solr/example/files/conf/solrconfig.xml b/solr/example/files/conf/solrconfig.xml index ae858ec8220..748bd0f221e 100644 --- a/solr/example/files/conf/solrconfig.xml +++ b/solr/example/files/conf/solrconfig.xml @@ -703,7 +703,12 @@ explicit 10 - + + + + + - - 5 - ----- - -A value of 5 for `xsltCacheLifetimeSeconds` is good for development, to see XSLT changes quickly. For production you probably want a much higher value. - == JSON Response Writer -A very commonly used Response Writer is the `JsonResponseWriter`, which formats output in JavaScript Object Notation (JSON), a lightweight data interchange format specified in specified in RFC 4627. Setting the `wt` parameter to `json` invokes this Response Writer. +The default Solr Response Writer is the `JsonResponseWriter`, which formats output in JavaScript Object Notation (JSON), a lightweight data interchange format specified in specified in RFC 4627. If you do not set the `wt` parameter in your request, you will get JSON by default. -Here is a sample response for a simple query like `q=id:VS1GB400C3&wt=json`: +Here is a sample response for a simple query like `q=id:VS1GB400C3`: [source,json] ---- @@ -115,9 +53,7 @@ Here is a sample response for a simple query like `q=id:VS1GB400C3&wt=json`: "status":0, "QTime":7, "params":{ - "q":"id:VS1GB400C3", - "indent":"on", - "wt":"json"}}, + "q":"id:VS1GB400C3"}}, "response":{"numFound":1,"start":0,"maxScore":2.3025851,"docs":[ { "id":"VS1GB400C3", @@ -193,6 +129,68 @@ With input of `NamedList("a"=1, "bar"="foo", null=3, null=null)`, the output wou * http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html * http://www.theurer.cc/blog/2005/12/15/web-services-json-dump-your-proxy/ + +== Standard XML Response Writer + +The XML Response Writer is the most general purpose and reusable Response Writer currently included with Solr. It is the format used in most discussions and documentation about the response of Solr queries. + +Note that the XSLT Response Writer can be used to convert the XML produced by this writer to other vocabularies or text-based formats. + +The behavior of the XML Response Writer can be driven by the following query parameters. + +=== The version Parameter + +The `version` parameter determines the XML protocol used in the response. Clients are strongly encouraged to _always_ specify the protocol version, so as to ensure that the format of the response they receive does not change unexpectedly if the Solr server is upgraded and a new default format is introduced. + +The only currently supported version value is `2.2`. The format of the `responseHeader` changed to use the same `` structure as the rest of the response. + +The default value is the latest supported. + +=== stylesheet Parameter + +The `stylesheet` parameter can be used to direct Solr to include a `` declaration in the XML response it returns. + +The default behavior is not to return any stylesheet declaration at all. + +[IMPORTANT] +==== +Use of the `stylesheet` parameter is discouraged, as there is currently no way to specify external stylesheets, and no stylesheets are provided in the Solr distributions. This is a legacy parameter, which may be developed further in a future release. +==== + +=== indent Parameter + +If the `indent` parameter is used, and has a non-blank value, then Solr will make some attempts at indenting its XML response to make it more readable by humans. + +The default behavior is not to indent. + +== XSLT Response Writer + +The XSLT Response Writer applies an XML stylesheet to output. It can be used for tasks such as formatting results for an RSS feed. + +=== tr Parameter + +The XSLT Response Writer accepts one parameter: the `tr` parameter, which identifies the XML transformation to use. The transformation must be found in the Solr `conf/xslt` directory. + +The Content-Type of the response is set according to the `` statement in the XSLT transform, for example: `` + +=== XSLT Configuration + +The example below, from the `sample_techproducts_configs` <> in the Solr distribution, shows how the XSLT Response Writer is configured. + +[source,xml] +---- + + + 5 + +---- + +A value of 5 for `xsltCacheLifetimeSeconds` is good for development, to see XSLT changes quickly. For production you probably want a much higher value. + == Binary Response Writer This is a custom binary format used by Solr for inter-node communication as well as client-server communication. SolrJ uses this as the default for indexing as well as querying. See <> for more details. diff --git a/solr/solr-ref-guide/src/result-grouping.adoc b/solr/solr-ref-guide/src/result-grouping.adoc index a0bb076debf..8a51e123372 100644 --- a/solr/solr-ref-guide/src/result-grouping.adoc +++ b/solr/solr-ref-guide/src/result-grouping.adoc @@ -126,7 +126,7 @@ All of the following sample queries work with Solr's "`bin/solr -e techproducts` In this example, we will group results based on the `manu_exact` field, which specifies the manufacturer of the items in the sample dataset. -`\http://localhost:8983/solr/techproducts/select?wt=json&indent=true&fl=id,name&q=solr+memory&group=true&group.field=manu_exact` +`\http://localhost:8983/solr/techproducts/select?fl=id,name&q=solr+memory&group=true&group.field=manu_exact` [source,json] ---- @@ -177,7 +177,7 @@ The response indicates that there are six total matches for our query. For each We can run the same query with the request parameter `group.main=true`. This will format the results as a single flat document list. This flat format does not include as much information as the normal result grouping query results – notably the `numFound` in each group – but it may be easier for existing Solr clients to parse. -`\http://localhost:8983/solr/techproducts/select?wt=json&indent=true&fl=id,name,manufacturer&q=solr+memory&group=true&group.field=manu_exact&group.main=true` +`\http://localhost:8983/solr/techproducts/select?fl=id,name,manufacturer&q=solr+memory&group=true&group.field=manu_exact&group.main=true` [source,json] ---- @@ -191,8 +191,7 @@ We can run the same query with the request parameter `group.main=true`. This wil "q":"solr memory", "group.field":"manu_exact", "group.main":"true", - "group":"true", - "wt":"json"}}, + "group":"true"}}, "grouped":{}, "response":{"numFound":6,"start":0,"docs":[ { @@ -218,7 +217,7 @@ We can run the same query with the request parameter `group.main=true`. This wil In this example, we will use the `group.query` parameter to find the top three results for "memory" in two different price ranges: 0.00 to 99.99, and over 100. -`\http://localhost:8983/solr/techproducts/select?wt=json&indent=true&fl=name,price&q=memory&group=true&group.query=price:[0+TO+99.99]&group.query=price:[100+TO+*]&group.limit=3` +`\http://localhost:8983/solr/techproducts/select?indent=true&fl=name,price&q=memory&group=true&group.query=price:[0+TO+99.99]&group.query=price:[100+TO+*]&group.limit=3` [source,json] ---- @@ -233,8 +232,7 @@ In this example, we will use the `group.query` parameter to find the top three r "group.limit":"3", "group.query":["price:[0 TO 99.99]", "price:[100 TO *]"], - "group":"true", - "wt":"json"}}, + "group":"true"}}, "grouped":{ "price:[0 TO 99.99]":{ "matches":5, diff --git a/solr/solr-ref-guide/src/schema-api.adoc b/solr/solr-ref-guide/src/schema-api.adoc index a12eeb5d4fa..c120e0a93ea 100644 --- a/solr/solr-ref-guide/src/schema-api.adoc +++ b/solr/solr-ref-guide/src/schema-api.adoc @@ -420,7 +420,7 @@ Get the entire schema in JSON. [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema?wt=json +curl http://localhost:8983/solr/gettingstarted/schema ---- [source,json] @@ -609,7 +609,7 @@ Get a list of all fields. [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema/fields?wt=json +curl http://localhost:8983/solr/gettingstarted/schema/fields ---- The sample output below has been truncated to only show a few fields. @@ -682,7 +682,7 @@ Get a list of all dynamic field declarations: [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema/dynamicfields?wt=json +curl http://localhost:8983/solr/gettingstarted/schema/dynamicfields ---- The sample output below has been truncated. @@ -765,7 +765,7 @@ Get a list of all field types. [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema/fieldtypes?wt=json +curl http://localhost:8983/solr/gettingstarted/schema/fieldtypes ---- The sample output below has been truncated to show a few different field types from different parts of the list. @@ -853,7 +853,7 @@ Get a list of all copyFields. [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema/copyfields?wt=json +curl http://localhost:8983/solr/gettingstarted/schema/copyfields ---- The sample output below has been truncated to the first few copy definitions. @@ -914,7 +914,7 @@ Get the schema name. [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema/name?wt=json +curl http://localhost:8983/solr/gettingstarted/schema/name ---- [source,json] @@ -954,7 +954,7 @@ Get the schema version [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema/version?wt=json +curl http://localhost:8983/solr/gettingstarted/schema/version ---- [source,json] @@ -995,7 +995,7 @@ List the uniqueKey. [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema/uniquekey?wt=json +curl http://localhost:8983/solr/gettingstarted/schema/uniquekey ---- [source,json] @@ -1035,7 +1035,7 @@ Get the similarity implementation. [source,bash] ---- -curl http://localhost:8983/solr/gettingstarted/schema/similarity?wt=json +curl http://localhost:8983/solr/gettingstarted/schema/similarity ---- [source,json] diff --git a/solr/solr-ref-guide/src/suggester.adoc b/solr/solr-ref-guide/src/suggester.adoc index 1950fc7dcab..18a7def015f 100644 --- a/solr/solr-ref-guide/src/suggester.adoc +++ b/solr/solr-ref-guide/src/suggester.adoc @@ -414,7 +414,7 @@ Example query: [source,text] ---- -http://localhost:8983/solr/techproducts/suggest?suggest=true&suggest.build=true&suggest.dictionary=mySuggester&wt=json&suggest.q=elec +http://localhost:8983/solr/techproducts/suggest?suggest=true&suggest.build=true&suggest.dictionary=mySuggester&suggest.q=elec ---- In this example, we've simply requested the string 'elec' with the `suggest.q` parameter and requested that the suggestion dictionary be built with `suggest.build` (note, however, that you would likely not want to build the index on every query - instead you should use `buildOnCommit` or `buildOnOptimize` if you have regularly changing documents). @@ -464,8 +464,7 @@ Example query: [source,text] ---- -http://localhost:8983/solr/techproducts/suggest?suggest=true& \ - suggest.dictionary=mySuggester&suggest.dictionary=altSuggester&wt=json&suggest.q=elec +http://localhost:8983/solr/techproducts/suggest?suggest=true&suggest.dictionary=mySuggester&suggest.dictionary=altSuggester&suggest.q=elec ---- In this example we have sent the string 'elec' as the `suggest.q` parameter and named two `suggest.dictionary` definitions to be used. @@ -535,7 +534,7 @@ Example context filtering suggest query: [source,text] ---- -http://localhost:8983/solr/techproducts/suggest?suggest=true&suggest.build=true&suggest.dictionary=mySuggester&wt=json&suggest.q=c&suggest.cfq=memory +http://localhost:8983/solr/techproducts/suggest?suggest=true&suggest.build=true&suggest.dictionary=mySuggester&suggest.q=c&suggest.cfq=memory ---- The suggester will only bring back suggestions for products tagged with 'cat=memory'. diff --git a/solr/solr-ref-guide/src/the-terms-component.adoc b/solr/solr-ref-guide/src/the-terms-component.adoc index c8b51ca8b7a..9f10fb633c9 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: ---- -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: diff --git a/solr/solr-ref-guide/src/transforming-result-documents.adoc b/solr/solr-ref-guide/src/transforming-result-documents.adoc index 754060db295..b5b1cff0daa 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] ---- diff --git a/solr/solr-ref-guide/src/using-javascript.adoc b/solr/solr-ref-guide/src/using-javascript.adoc index d2247fb25e2..62c681f603f 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 <>, which are easily interpreted in JavaScript. Just add `wt=json` to the request URL to have responses sent as JSON. +By default, Solr sends <>, 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: diff --git a/solr/solr-ref-guide/src/using-python.adoc b/solr/solr-ref-guide/src/using-python.adoc index 84a7b4cbaec..2c5148671d5 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] ---- 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 ab029afbb6c..17817bdc441 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"); 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 607d0ebb54e..6e23d45d303 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -850,6 +850,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)) { 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 b6209bff906..12cad01f6a1 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 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 11e28a64e82..2769d9b32a5 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); } diff --git a/solr/webapp/web/js/angular/controllers/query.js b/solr/webapp/web/js/angular/controllers/query.js index 3a44cbd5a96..63f0830526a 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; diff --git a/solr/webapp/web/partials/query.html b/solr/webapp/web/partials/query.html index d68d236486c..2a773550508 100644 --- a/solr/webapp/web/partials/query.html +++ b/solr/webapp/web/partials/query.html @@ -78,6 +78,7 @@ limitations under the License. wt -