SOLR-10494: Make default response format JSON (wt=json), and also indent text responses formats (indent=on) by default

This commit is contained in:
Chris Hostetter 2017-07-24 08:42:02 -07:00
parent a323f55d79
commit 6a59253ec3
78 changed files with 487 additions and 415 deletions

View File

@ -126,6 +126,11 @@ Jetty 9.3.14.v20161028
Upgrading from Solr 6.x 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 * 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 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 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-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 ================== ================== 6.7.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -160,9 +160,9 @@ public class TestHierarchicalDocBuilder extends AbstractDataImportHandlerTestCas
int totalDocsNum = parentsNum + childrenNum + grandChildrenNum; int totalDocsNum = parentsNum + childrenNum + grandChildrenNum;
String resp = runFullImport(THREE_LEVEL_HIERARCHY_CONFIG); String resp = runFullImport(THREE_LEVEL_HIERARCHY_CONFIG);
String xpath = "//arr[@name='documents']/lst/arr[@name='id' and .='"+parentId1+"']/../"+ String xpath = "//arr[@name='documents']/lst[arr[@name='id']/str='"+parentId1+"']/"+
"arr[@name='_childDocuments_']/lst/arr[@name='id' and .='"+childId+"']/../"+ "arr[@name='_childDocuments_']/lst[arr[@name='id']/str='"+childId+"']/"+
"arr[@name='_childDocuments_']/lst/arr[@name='id' and .='"+grandChildrenIds.get(0)+"']"; "arr[@name='_childDocuments_']/lst[arr[@name='id']/str='"+grandChildrenIds.get(0)+"']";
String results = TestHarness.validateXPath(resp, String results = TestHarness.validateXPath(resp,
xpath); xpath);
assertTrue("Debug documents does not contain child documents\n"+resp+"\n"+ xpath+ assertTrue("Debug documents does not contain child documents\n"+resp+"\n"+ xpath+

View File

@ -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 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 # Assemble training data

View File

@ -2565,8 +2565,8 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab
static{ static{
HashMap<String, QueryResponseWriter> m= new HashMap<>(15, 1); HashMap<String, QueryResponseWriter> m= new HashMap<>(15, 1);
m.put("xml", new XMLResponseWriter()); m.put("xml", new XMLResponseWriter());
m.put("standard", m.get("xml"));
m.put(CommonParams.JSON, new JSONResponseWriter()); m.put(CommonParams.JSON, new JSONResponseWriter());
m.put("standard", m.get(CommonParams.JSON));
m.put("geojson", new GeoJSONResponseWriter()); m.put("geojson", new GeoJSONResponseWriter());
m.put("graphml", new GraphMLResponseWriter()); m.put("graphml", new GraphMLResponseWriter());
m.put("python", new PythonResponseWriter()); m.put("python", new PythonResponseWriter());

View File

@ -84,7 +84,7 @@ public abstract class TextResponseWriter implements PushWriter {
this.req = req; this.req = req;
this.rsp = rsp; this.rsp = rsp;
String indent = req.getParams().get("indent"); 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; doIndent=true;
} }
returnFields = rsp.getReturnFields(); returnFields = rsp.getReturnFields();

View File

@ -63,6 +63,7 @@ public class DirectSolrConnection
* For example: * For example:
* *
* String json = solr.request( "/select?qt=dismax&amp;wt=json&amp;q=...", null ); * String json = solr.request( "/select?qt=dismax&amp;wt=json&amp;q=...", null );
* String xml = solr.request( "/select?qt=dismax&amp;wt=xml&amp;q=...", null );
* String xml = solr.request( "/update", "&lt;add&gt;&lt;doc&gt;&lt;field ..." ); * String xml = solr.request( "/update", "&lt;add&gt;&lt;doc&gt;&lt;field ..." );
*/ */
public String request( String pathAndParams, String body ) throws Exception public String request( String pathAndParams, String body ) throws Exception

View File

@ -716,7 +716,12 @@
<lst name="defaults"> <lst name="defaults">
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<int name="rows">10</int> <int name="rows">10</int>
<!-- <str name="df">text</str> --> <!-- Default search field
<str name="df">text</str>
-->
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
</lst> </lst>
<!-- In addition to defaults, "appends" params can be specified <!-- In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of to identify values which should be appended to the list of

View File

@ -21,6 +21,7 @@ import java.util.Collections;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.core.CoreContainer; import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest; import org.apache.solr.request.LocalSolrQueryRequest;
@ -109,8 +110,14 @@ public class TestCrossCoreJoin extends SolrTestCaseJ4 {
public String query(SolrCore core, SolrQueryRequest req) throws Exception { public String query(SolrCore core, SolrQueryRequest req) throws Exception {
String handler = "standard"; String handler = "standard";
if (req.getParams().get("qt") != null) if (req.getParams().get("qt") != null) {
handler = req.getParams().get("qt"); handler = req.getParams().get("qt");
}
if (req.getParams().get("wt") == null){
ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
params.set("wt", "xml");
req.setParams(params);
}
SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp)); SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
core.execute(core.getRequestHandler(handler), req, rsp); core.execute(core.getRequestHandler(handler), req, rsp);

View File

@ -56,6 +56,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
private static final String ONE_NODE_COLLECTION = "onenodecollection"; private static final String ONE_NODE_COLLECTION = "onenodecollection";
private final boolean onlyLeaderIndexes = random().nextBoolean(); private final boolean onlyLeaderIndexes = random().nextBoolean();
public BasicDistributedZk2Test() { public BasicDistributedZk2Test() {
super(); super();
// we need DVs on point fields to compute stats & facets // we need DVs on point fields to compute stats & facets

View File

@ -265,7 +265,7 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
DocCollection coll = cloudClient.getZkStateReader().getClusterState().getCollection(collection); DocCollection coll = cloudClient.getZkStateReader().getClusterState().getCollection(collection);
for (Slice slice : coll.getActiveSlices()) { for (Slice slice : coll.getActiveSlices()) {
for (Replica replica : slice.getReplicas()) { for (Replica replica : slice.getReplicas()) {
String uri = "" + replica.get(ZkStateReader.BASE_URL_PROP) + "/" + replica.get(ZkStateReader.CORE_NAME_PROP) + "/config?wt=json"; String uri = "" + replica.get(ZkStateReader.BASE_URL_PROP) + "/" + replica.get(ZkStateReader.CORE_NAME_PROP) + "/config";
Map respMap = getAsMap(cloudClient, uri); Map respMap = getAsMap(cloudClient, uri);
Long maxTime = (Long) (getObjectByPath(respMap, true, asList("config", "updateHandler", "autoSoftCommit", "maxTime"))); Long maxTime = (Long) (getObjectByPath(respMap, true, asList("config", "updateHandler", "autoSoftCommit", "maxTime")));
ret.put(replica.getCoreName(), maxTime); ret.put(replica.getCoreName(), maxTime);

View File

@ -286,7 +286,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
// Checking error when no configuration name is specified in request // Checking error when no configuration name is specified in request
Map map = postDataAndGetResponse(solrCluster.getSolrClient(), Map map = postDataAndGetResponse(solrCluster.getSolrClient(),
solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString() solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString()
+ "/admin/configs?action=UPLOAD&wt=json", emptyData, null, null); + "/admin/configs?action=UPLOAD", emptyData, null, null);
assertNotNull(map); assertNotNull(map);
long statusCode = (long) getObjectByPath(map, false, long statusCode = (long) getObjectByPath(map, false,
Arrays.asList("responseHeader", "status")); Arrays.asList("responseHeader", "status"));
@ -305,7 +305,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
// Checking error when configuration name specified already exists // Checking error when configuration name specified already exists
map = postDataAndGetResponse(solrCluster.getSolrClient(), map = postDataAndGetResponse(solrCluster.getSolrClient(),
solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString() solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString()
+ "/admin/configs?action=UPLOAD&wt=json&name=myconf", emptyData, null, null); + "/admin/configs?action=UPLOAD&name=myconf", emptyData, null, null);
assertNotNull(map); assertNotNull(map);
statusCode = (long) getObjectByPath(map, false, statusCode = (long) getObjectByPath(map, false,
Arrays.asList("responseHeader", "status")); Arrays.asList("responseHeader", "status"));
@ -416,7 +416,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
assertFalse(configManager.configExists(configSetName+suffix)); assertFalse(configManager.configExists(configSetName+suffix));
Map map = postDataAndGetResponse(solrCluster.getSolrClient(), Map map = postDataAndGetResponse(solrCluster.getSolrClient(),
solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/admin/configs?action=UPLOAD&wt=json&name="+configSetName+suffix, solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/admin/configs?action=UPLOAD&name="+configSetName+suffix,
sampleZippedConfig, username, password); sampleZippedConfig, username, password);
assertNotNull(map); assertNotNull(map);
long statusCode = (long) getObjectByPath(map, false, Arrays.asList("responseHeader", "status")); long statusCode = (long) getObjectByPath(map, false, Arrays.asList("responseHeader", "status"));

View File

@ -124,11 +124,11 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
"'create-requesthandler' : { 'name' : '/runtime', 'class': 'org.apache.solr.core.RuntimeLibReqHandler' , 'runtimeLib':true }" + "'create-requesthandler' : { 'name' : '/runtime', 'class': 'org.apache.solr.core.RuntimeLibReqHandler' , 'runtimeLib':true }" +
"}"; "}";
RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "requestHandler", "/runtime", "class"), Arrays.asList("overlay", "requestHandler", "/runtime", "class"),
"org.apache.solr.core.RuntimeLibReqHandler", 10); "org.apache.solr.core.RuntimeLibReqHandler", 10);
@ -138,15 +138,15 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
"'add-runtimelib' : { 'name' : 'signedjar' ,'version':1}\n" + "'add-runtimelib' : { 'name' : 'signedjar' ,'version':1}\n" +
"}"; "}";
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "runtimeLib", blobName, "version"), Arrays.asList("overlay", "runtimeLib", blobName, "version"),
1l, 10); 1l, 10);
Map map = TestSolrConfigHandler.getRespMap("/runtime?wt=json", client); Map map = TestSolrConfigHandler.getRespMap("/runtime", client);
String s = (String) Utils.getObjectByPath(map, false, Arrays.asList("error", "msg")); String s = (String) Utils.getObjectByPath(map, false, Arrays.asList("error", "msg"));
assertNotNull(TestBlobHandler.getAsString(map), s); assertNotNull(TestBlobHandler.getAsString(map), s);
assertTrue(TestBlobHandler.getAsString(map), s.contains("should be signed with one of the keys in ZK /keys/exe")); assertTrue(TestBlobHandler.getAsString(map), s.contains("should be signed with one of the keys in ZK /keys/exe"));
@ -157,15 +157,15 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
"'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'QKqHtd37QN02iMW9UEgvAO9g9qOOuG5vEBNkbUsN7noc2hhXKic/ABFIOYJA9PKw61mNX2EmNFXOcO3WClYdSw=='}\n" + "'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'QKqHtd37QN02iMW9UEgvAO9g9qOOuG5vEBNkbUsN7noc2hhXKic/ABFIOYJA9PKw61mNX2EmNFXOcO3WClYdSw=='}\n" +
"}"; "}";
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "runtimeLib", blobName, "sig"), Arrays.asList("overlay", "runtimeLib", blobName, "sig"),
wrongSig, 10); wrongSig, 10);
map = TestSolrConfigHandler.getRespMap("/runtime?wt=json", client); map = TestSolrConfigHandler.getRespMap("/runtime", client);
s = (String) Utils.getObjectByPath(map, false, Arrays.asList("error", "msg")); s = (String) Utils.getObjectByPath(map, false, Arrays.asList("error", "msg"));
assertNotNull(TestBlobHandler.getAsString(map), s);//No key matched signature for jar assertNotNull(TestBlobHandler.getAsString(map), s);//No key matched signature for jar
assertTrue(TestBlobHandler.getAsString(map), s.contains("No key matched signature for jar")); assertTrue(TestBlobHandler.getAsString(map), s.contains("No key matched signature for jar"));
@ -176,17 +176,17 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
"'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'YkTQgOtvcM/H/5EQdABGl3wjjrPhonAGlouIx59vppBy2cZEofX3qX1yZu5sPNRmJisNXEuhHN2149dxeUmk2Q=='}\n" + "'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'YkTQgOtvcM/H/5EQdABGl3wjjrPhonAGlouIx59vppBy2cZEofX3qX1yZu5sPNRmJisNXEuhHN2149dxeUmk2Q=='}\n" +
"}"; "}";
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "runtimeLib", blobName, "sig"), Arrays.asList("overlay", "runtimeLib", blobName, "sig"),
rightSig, 10); rightSig, 10);
map = TestSolrConfigHandler.testForResponseElement(client, map = TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/runtime?wt=json", "/runtime",
null, null,
Arrays.asList("class"), Arrays.asList("class"),
"org.apache.solr.core.RuntimeLibReqHandler", 10); "org.apache.solr.core.RuntimeLibReqHandler", 10);
@ -197,17 +197,17 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
"'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'VJPMTxDf8Km3IBj2B5HWkIOqeM/o+HHNobOYCNA3WjrEVfOMZbMMqS1Lo7uLUUp//RZwOGkOhrUhuPNY1z2CGEIKX2/m8VGH64L14d52oSvFiwhoTDDuuyjW1TFGu35D'}\n" + "'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'VJPMTxDf8Km3IBj2B5HWkIOqeM/o+HHNobOYCNA3WjrEVfOMZbMMqS1Lo7uLUUp//RZwOGkOhrUhuPNY1z2CGEIKX2/m8VGH64L14d52oSvFiwhoTDDuuyjW1TFGu35D'}\n" +
"}"; "}";
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "runtimeLib", blobName, "sig"), Arrays.asList("overlay", "runtimeLib", blobName, "sig"),
rightSig, 10); rightSig, 10);
map = TestSolrConfigHandler.testForResponseElement(client, map = TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/runtime?wt=json", "/runtime",
null, null,
Arrays.asList("class"), Arrays.asList("class"),
"org.apache.solr.core.RuntimeLibReqHandler", 10); "org.apache.solr.core.RuntimeLibReqHandler", 10);

View File

@ -73,7 +73,7 @@ public class TestConfigSetImmutable extends RestTestBase {
String payload = "{\n" + String payload = "{\n" +
"'create-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy'}\n" + "'create-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy'}\n" +
"}"; "}";
String uri = "/config?wt=json"; String uri = "/config";
String response = restTestHarness.post(uri, SolrTestCaseJ4.json(payload)); String response = restTestHarness.post(uri, SolrTestCaseJ4.json(payload));
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNotNull(map.get("error")); assertNotNull(map.get("error"));
@ -91,7 +91,7 @@ public class TestConfigSetImmutable extends RestTestBase {
" },\n" + " },\n" +
" }"; " }";
String response = restTestHarness.post("/schema?wt=json", json(payload)); String response = restTestHarness.post("/schema", json(payload));
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNotNull(map.get("errors")); assertNotNull(map.get("errors"));
assertTrue(map.get("errors").toString().contains("immutable")); assertTrue(map.get("errors").toString().contains("immutable"));

View File

@ -74,10 +74,10 @@ public class TestCustomStream extends AbstractFullDistribZkTestBase {
"}"; "}";
RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client,"/config?wt=json",payload); TestSolrConfigHandler.runConfigCommand(client,"/config",payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "expressible", "hello", "class"), Arrays.asList("overlay", "expressible", "hello", "class"),
"org.apache.solr.core.HelloStream",10); "org.apache.solr.core.HelloStream",10);

View File

@ -79,10 +79,10 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
"'add-runtimelib' : { 'name' : 'colltest' ,'version':1}\n" + "'add-runtimelib' : { 'name' : 'colltest' ,'version':1}\n" +
"}"; "}";
RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "runtimeLib", blobName, "version"), Arrays.asList("overlay", "runtimeLib", blobName, "version"),
1l, 10); 1l, 10);
@ -93,15 +93,15 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
"}"; "}";
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client,"/config?wt=json",payload); TestSolrConfigHandler.runConfigCommand(client,"/config",payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "requestHandler", "/test1", "class"), Arrays.asList("overlay", "requestHandler", "/test1", "class"),
"org.apache.solr.core.BlobStoreTestRequestHandler",10); "org.apache.solr.core.BlobStoreTestRequestHandler",10);
Map map = TestSolrConfigHandler.getRespMap("/test1?wt=json", client); Map map = TestSolrConfigHandler.getRespMap("/test1", client);
assertNotNull(TestBlobHandler.getAsString(map), map = (Map) map.get("error")); assertNotNull(TestBlobHandler.getAsString(map), map = (Map) map.get("error"));
assertTrue(TestBlobHandler.getAsString(map), map.get("msg").toString().contains(".system collection not available")); assertTrue(TestBlobHandler.getAsString(map), map.get("msg").toString().contains(".system collection not available"));
@ -110,7 +110,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
TestBlobHandler.createSystemCollection(getHttpSolrClient(baseURL, randomClient.getHttpClient())); TestBlobHandler.createSystemCollection(getHttpSolrClient(baseURL, randomClient.getHttpClient()));
waitForRecoveriesToFinish(".system", true); waitForRecoveriesToFinish(".system", true);
map = TestSolrConfigHandler.getRespMap("/test1?wt=json", client); map = TestSolrConfigHandler.getRespMap("/test1", client);
assertNotNull(map = (Map) map.get("error")); assertNotNull(map = (Map) map.get("error"));
@ -122,11 +122,11 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
" }\n" + " }\n" +
" }"; " }";
TestSolrConfigHandler.runConfigCommand(client,"/config/params?wt=json",payload); TestSolrConfigHandler.runConfigCommand(client,"/config/params",payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
client, client,
null, null,
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
Arrays.asList("response", "params", "watched", "x"), Arrays.asList("response", "params", "watched", "x"),
"X val", "X val",
@ -136,7 +136,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
for(int i=0;i<100;i++) { for(int i=0;i<100;i++) {
map = TestSolrConfigHandler.getRespMap("/test1?wt=json", client); map = TestSolrConfigHandler.getRespMap("/test1", client);
if("X val".equals(map.get("x"))){ if("X val".equals(map.get("x"))){
success = true; success = true;
break; break;
@ -157,11 +157,11 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
"'create-queryResponseWriter' : { 'name' : 'json1', 'class': 'org.apache.solr.core.RuntimeLibResponseWriter' , 'runtimeLib':true }" + "'create-queryResponseWriter' : { 'name' : 'json1', 'class': 'org.apache.solr.core.RuntimeLibResponseWriter' , 'runtimeLib':true }" +
"}"; "}";
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
Map result = TestSolrConfigHandler.testForResponseElement(client, Map result = TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "requestHandler", "/runtime", "class"), Arrays.asList("overlay", "requestHandler", "/runtime", "class"),
"org.apache.solr.core.RuntimeLibReqHandler", 10); "org.apache.solr.core.RuntimeLibReqHandler", 10);
@ -170,7 +170,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
result = TestSolrConfigHandler.testForResponseElement(client, result = TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/runtime?wt=json", "/runtime",
null, null,
Arrays.asList("class"), Arrays.asList("class"),
"org.apache.solr.core.RuntimeLibReqHandler", 10); "org.apache.solr.core.RuntimeLibReqHandler", 10);
@ -198,10 +198,10 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
"'update-runtimelib' : { 'name' : 'colltest' ,'version':2}\n" + "'update-runtimelib' : { 'name' : 'colltest' ,'version':2}\n" +
"}"; "}";
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "runtimeLib", blobName, "version"), Arrays.asList("overlay", "runtimeLib", blobName, "version"),
2l, 10); 2l, 10);
@ -221,11 +221,11 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
" }\n" + " }\n" +
" }"; " }";
TestSolrConfigHandler.runConfigCommand(client,"/config/params?wt=json",payload); TestSolrConfigHandler.runConfigCommand(client,"/config/params",payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
client, client,
null, null,
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
Arrays.asList("response", "params", "watched", "x"), Arrays.asList("response", "params", "watched", "x"),
"X val", "X val",
@ -233,7 +233,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
client, client,
null, null,
"/test1?wt=json", "/test1",
cloudClient, cloudClient,
Arrays.asList("x"), Arrays.asList("x"),
"X val", "X val",
@ -246,11 +246,11 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
" }\n" + " }\n" +
" }"; " }";
TestSolrConfigHandler.runConfigCommand(client,"/config/params?wt=json",payload); TestSolrConfigHandler.runConfigCommand(client,"/config/params",payload);
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
client, client,
null, null,
"/test1?wt=json", "/test1",
cloudClient, cloudClient,
Arrays.asList("x"), Arrays.asList("x"),
"X val changed", "X val changed",

View File

@ -106,7 +106,7 @@ public class TestSolrConfigHandler extends RestTestBase {
public void testProperty() throws Exception { public void testProperty() throws Exception {
RestTestHarness harness = restTestHarness; RestTestHarness harness = restTestHarness;
Map confMap = getRespMap("/config?wt=json", harness); Map confMap = getRespMap("/config", harness);
assertNotNull(getObjectByPath(confMap, false, Arrays.asList("config", "requestHandler", "/admin/luke"))); assertNotNull(getObjectByPath(confMap, false, Arrays.asList("config", "requestHandler", "/admin/luke")));
assertNotNull(getObjectByPath(confMap, false, Arrays.asList("config", "requestHandler", "/admin/system"))); assertNotNull(getObjectByPath(confMap, false, Arrays.asList("config", "requestHandler", "/admin/system")));
assertNotNull(getObjectByPath(confMap, false, Arrays.asList("config", "requestHandler", "/admin/mbeans"))); assertNotNull(getObjectByPath(confMap, false, Arrays.asList("config", "requestHandler", "/admin/mbeans")));
@ -120,20 +120,20 @@ public class TestSolrConfigHandler extends RestTestBase {
String payload = "{\n" + String payload = "{\n" +
" 'set-property' : { 'updateHandler.autoCommit.maxDocs':100, 'updateHandler.autoCommit.maxTime':10 , 'requestDispatcher.requestParsers.addHttpRequestToContext':true} \n" + " 'set-property' : { 'updateHandler.autoCommit.maxDocs':100, 'updateHandler.autoCommit.maxTime':10 , 'requestDispatcher.requestParsers.addHttpRequestToContext':true} \n" +
" }"; " }";
runConfigCommand(harness, "/config?wt=json", payload); runConfigCommand(harness, "/config", payload);
Map m = (Map) getRespMap("/config/overlay?wt=json", harness).get("overlay"); Map m = (Map) getRespMap("/config/overlay", harness).get("overlay");
Map props = (Map) m.get("props"); Map props = (Map) m.get("props");
assertNotNull(props); assertNotNull(props);
assertEquals("100", String.valueOf(getObjectByPath(props, true, ImmutableList.of("updateHandler", "autoCommit", "maxDocs")))); assertEquals("100", String.valueOf(getObjectByPath(props, true, ImmutableList.of("updateHandler", "autoCommit", "maxDocs"))));
assertEquals("10", String.valueOf(getObjectByPath(props, true, ImmutableList.of("updateHandler", "autoCommit", "maxTime")))); assertEquals("10", String.valueOf(getObjectByPath(props, true, ImmutableList.of("updateHandler", "autoCommit", "maxTime"))));
m = getRespMap("/config/updateHandler?wt=json", harness); m = getRespMap("/config/updateHandler", harness);
assertNotNull(getObjectByPath(m, true, ImmutableList.of("config","updateHandler", "commitWithin", "softCommit"))); assertNotNull(getObjectByPath(m, true, ImmutableList.of("config","updateHandler", "commitWithin", "softCommit")));
assertNotNull(getObjectByPath(m, true, ImmutableList.of("config","updateHandler", "autoCommit", "maxDocs"))); assertNotNull(getObjectByPath(m, true, ImmutableList.of("config","updateHandler", "autoCommit", "maxDocs")));
assertNotNull(getObjectByPath(m, true, ImmutableList.of("config","updateHandler", "autoCommit", "maxTime"))); assertNotNull(getObjectByPath(m, true, ImmutableList.of("config","updateHandler", "autoCommit", "maxTime")));
m = (Map) getRespMap("/config?wt=json", harness).get("config"); m = (Map) getRespMap("/config", harness).get("config");
assertNotNull(m); assertNotNull(m);
assertEquals("100", String.valueOf(getObjectByPath(m, true, ImmutableList.of("updateHandler", "autoCommit", "maxDocs")))); assertEquals("100", String.valueOf(getObjectByPath(m, true, ImmutableList.of("updateHandler", "autoCommit", "maxDocs"))));
@ -142,9 +142,9 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
" 'unset-property' : 'updateHandler.autoCommit.maxDocs'} \n" + " 'unset-property' : 'updateHandler.autoCommit.maxDocs'} \n" +
" }"; " }";
runConfigCommand(harness, "/config?wt=json", payload); runConfigCommand(harness, "/config", payload);
m = (Map) getRespMap("/config/overlay?wt=json", harness).get("overlay"); m = (Map) getRespMap("/config/overlay", harness).get("overlay");
props = (Map) m.get("props"); props = (Map) m.get("props");
assertNotNull(props); assertNotNull(props);
assertNull(getObjectByPath(props, true, ImmutableList.of("updateHandler", "autoCommit", "maxDocs"))); assertNull(getObjectByPath(props, true, ImmutableList.of("updateHandler", "autoCommit", "maxDocs")));
@ -157,15 +157,15 @@ public class TestSolrConfigHandler extends RestTestBase {
" 'set-user-property' : { 'my.custom.variable.a':'MODIFIEDA'," + " 'set-user-property' : { 'my.custom.variable.a':'MODIFIEDA'," +
" 'my.custom.variable.b':'MODIFIEDB' } \n" + " 'my.custom.variable.b':'MODIFIEDB' } \n" +
" }"; " }";
runConfigCommand(harness, "/config?wt=json", payload); runConfigCommand(harness, "/config", payload);
Map m = (Map) getRespMap("/config/overlay?wt=json", harness).get("overlay"); Map m = (Map) getRespMap("/config/overlay", harness).get("overlay");
Map props = (Map) m.get("userProps"); Map props = (Map) m.get("userProps");
assertNotNull(props); assertNotNull(props);
assertEquals(props.get("my.custom.variable.a"), "MODIFIEDA"); assertEquals(props.get("my.custom.variable.a"), "MODIFIEDA");
assertEquals(props.get("my.custom.variable.b"), "MODIFIEDB"); assertEquals(props.get("my.custom.variable.b"), "MODIFIEDB");
m = (Map) getRespMap("/dump?wt=json&json.nl=map&initArgs=true", harness).get("initArgs"); m = (Map) getRespMap("/dump?json.nl=map&initArgs=true", harness).get("initArgs");
m = (Map) m.get(PluginInfo.DEFAULTS); m = (Map) m.get(PluginInfo.DEFAULTS);
assertEquals("MODIFIEDA", m.get("a")); assertEquals("MODIFIEDA", m.get("a"));
@ -191,11 +191,11 @@ public class TestSolrConfigHandler extends RestTestBase {
String payload = "{\n" + String payload = "{\n" +
"'create-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy'}\n" + "'create-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config/overlay?wt=json", "/config/overlay",
cloudSolrClient, cloudSolrClient,
Arrays.asList("overlay", "requestHandler", "/x", "startup"), Arrays.asList("overlay", "requestHandler", "/x", "startup"),
"lazy", "lazy",
@ -205,11 +205,11 @@ public class TestSolrConfigHandler extends RestTestBase {
"'update-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' ,registerPath :'/solr,/v2', " + "'update-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' ,registerPath :'/solr,/v2', " +
" 'startup' : 'lazy' , 'a':'b' , 'defaults': {'def_a':'def A val', 'multival':['a','b','c']}}\n" + " 'startup' : 'lazy' , 'a':'b' , 'defaults': {'def_a':'def A val', 'multival':['a','b','c']}}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config/overlay?wt=json", "/config/overlay",
cloudSolrClient, cloudSolrClient,
Arrays.asList("overlay", "requestHandler", "/x", "a"), Arrays.asList("overlay", "requestHandler", "/x", "a"),
"b", "b",
@ -222,10 +222,10 @@ public class TestSolrConfigHandler extends RestTestBase {
" 'defaults': {'a':'A','b':'B','c':'C'}}\n" + " 'defaults': {'a':'A','b':'B','c':'C'}}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config/overlay?wt=json", "/config/overlay",
cloudSolrClient, cloudSolrClient,
Arrays.asList("overlay", "requestHandler", "/dump", "defaults", "c" ), Arrays.asList("overlay", "requestHandler", "/dump", "defaults", "c" ),
"C", "C",
@ -233,7 +233,7 @@ public class TestSolrConfigHandler extends RestTestBase {
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/x?wt=json&getdefaults=true&json.nl=map", "/x?getdefaults=true&json.nl=map",
cloudSolrClient, cloudSolrClient,
Arrays.asList("getdefaults", "def_a"), Arrays.asList("getdefaults", "def_a"),
"def A val", "def A val",
@ -241,7 +241,7 @@ public class TestSolrConfigHandler extends RestTestBase {
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/x?wt=json&param=multival&json.nl=map", "/x?param=multival&json.nl=map",
cloudSolrClient, cloudSolrClient,
Arrays.asList("params", "multival"), Arrays.asList("params", "multival"),
Arrays.asList("a", "b", "c"), Arrays.asList("a", "b", "c"),
@ -250,12 +250,12 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'delete-requesthandler' : '/x'" + "'delete-requesthandler' : '/x'" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
boolean success = false; boolean success = false;
long startTime = System.nanoTime(); long startTime = System.nanoTime();
int maxTimeoutSeconds = 10; int maxTimeoutSeconds = 10;
while (TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutSeconds) { while (TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutSeconds) {
String uri = "/config/overlay?wt=json"; String uri = "/config/overlay";
Map m = testServerBaseUrl == null ? getRespMap(uri, writeHarness) : TestSolrConfigHandlerConcurrent.getAsMap(testServerBaseUrl + uri, cloudSolrClient); Map m = testServerBaseUrl == null ? getRespMap(uri, writeHarness) : TestSolrConfigHandlerConcurrent.getAsMap(testServerBaseUrl + uri, cloudSolrClient);
if (null == Utils.getObjectByPath(m, true, Arrays.asList("overlay", "requestHandler", "/x", "a"))) { if (null == Utils.getObjectByPath(m, true, Arrays.asList("overlay", "requestHandler", "/x", "a"))) {
success = true; success = true;
@ -269,10 +269,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'create-queryconverter' : { 'name' : 'qc', 'class': 'org.apache.solr.spelling.SpellingQueryConverter'}\n" + "'create-queryconverter' : { 'name' : 'qc', 'class': 'org.apache.solr.spelling.SpellingQueryConverter'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "queryConverter", "qc", "class"), Arrays.asList("config", "queryConverter", "qc", "class"),
"org.apache.solr.spelling.SpellingQueryConverter", "org.apache.solr.spelling.SpellingQueryConverter",
@ -280,10 +280,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'update-queryconverter' : { 'name' : 'qc', 'class': 'org.apache.solr.spelling.SuggestQueryConverter'}\n" + "'update-queryconverter' : { 'name' : 'qc', 'class': 'org.apache.solr.spelling.SuggestQueryConverter'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "queryConverter", "qc", "class"), Arrays.asList("config", "queryConverter", "qc", "class"),
"org.apache.solr.spelling.SuggestQueryConverter", "org.apache.solr.spelling.SuggestQueryConverter",
@ -292,10 +292,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'delete-queryconverter' : 'qc'" + "'delete-queryconverter' : 'qc'" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "queryConverter", "qc"), Arrays.asList("config", "queryConverter", "qc"),
null, null,
@ -304,10 +304,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'create-searchcomponent' : { 'name' : 'tc', 'class': 'org.apache.solr.handler.component.TermsComponent'}\n" + "'create-searchcomponent' : { 'name' : 'tc', 'class': 'org.apache.solr.handler.component.TermsComponent'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "searchComponent", "tc", "class"), Arrays.asList("config", "searchComponent", "tc", "class"),
"org.apache.solr.handler.component.TermsComponent", "org.apache.solr.handler.component.TermsComponent",
@ -315,10 +315,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'update-searchcomponent' : { 'name' : 'tc', 'class': 'org.apache.solr.handler.component.TermVectorComponent' }\n" + "'update-searchcomponent' : { 'name' : 'tc', 'class': 'org.apache.solr.handler.component.TermVectorComponent' }\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "searchComponent", "tc", "class"), Arrays.asList("config", "searchComponent", "tc", "class"),
"org.apache.solr.handler.component.TermVectorComponent", "org.apache.solr.handler.component.TermVectorComponent",
@ -327,10 +327,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'delete-searchcomponent' : 'tc'" + "'delete-searchcomponent' : 'tc'" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "searchComponent", "tc"), Arrays.asList("config", "searchComponent", "tc"),
null, null,
@ -339,10 +339,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'create-valuesourceparser' : { 'name' : 'cu', 'class': 'org.apache.solr.core.CountUsageValueSourceParser'}\n" + "'create-valuesourceparser' : { 'name' : 'cu', 'class': 'org.apache.solr.core.CountUsageValueSourceParser'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "valueSourceParser", "cu", "class"), Arrays.asList("config", "valueSourceParser", "cu", "class"),
"org.apache.solr.core.CountUsageValueSourceParser", "org.apache.solr.core.CountUsageValueSourceParser",
@ -353,10 +353,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'update-valuesourceparser' : { 'name' : 'cu', 'class': 'org.apache.solr.search.function.NvlValueSourceParser'}\n" + "'update-valuesourceparser' : { 'name' : 'cu', 'class': 'org.apache.solr.search.function.NvlValueSourceParser'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "valueSourceParser", "cu", "class"), Arrays.asList("config", "valueSourceParser", "cu", "class"),
"org.apache.solr.search.function.NvlValueSourceParser", "org.apache.solr.search.function.NvlValueSourceParser",
@ -365,10 +365,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'delete-valuesourceparser' : 'cu'" + "'delete-valuesourceparser' : 'cu'" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "valueSourceParser", "cu"), Arrays.asList("config", "valueSourceParser", "cu"),
null, null,
@ -379,10 +379,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'create-transformer' : { 'name' : 'mytrans', 'class': 'org.apache.solr.response.transform.ValueAugmenterFactory', 'value':'5'}\n" + "'create-transformer' : { 'name' : 'mytrans', 'class': 'org.apache.solr.response.transform.ValueAugmenterFactory', 'value':'5'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "transformer", "mytrans", "class"), Arrays.asList("config", "transformer", "mytrans", "class"),
"org.apache.solr.response.transform.ValueAugmenterFactory", "org.apache.solr.response.transform.ValueAugmenterFactory",
@ -391,10 +391,10 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'update-transformer' : { 'name' : 'mytrans', 'class': 'org.apache.solr.response.transform.ValueAugmenterFactory', 'value':'6'}\n" + "'update-transformer' : { 'name' : 'mytrans', 'class': 'org.apache.solr.response.transform.ValueAugmenterFactory', 'value':'6'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "transformer", "mytrans", "value"), Arrays.asList("config", "transformer", "mytrans", "value"),
"6", "6",
@ -404,10 +404,10 @@ public class TestSolrConfigHandler extends RestTestBase {
"'delete-transformer' : 'mytrans'," + "'delete-transformer' : 'mytrans'," +
"'create-initparams' : { 'name' : 'hello', 'key':'val'}\n" + "'create-initparams' : { 'name' : 'hello', 'key':'val'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
Map map = testForResponseElement(writeHarness, Map map = testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "transformer", "mytrans"), Arrays.asList("config", "transformer", "mytrans"),
null, null,
@ -431,10 +431,10 @@ public class TestSolrConfigHandler extends RestTestBase {
" }\n" + " }\n" +
" }\n" + " }\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
map = testForResponseElement(writeHarness, map = testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "searchComponent","myspellcheck", "spellchecker", "class"), Arrays.asList("config", "searchComponent","myspellcheck", "spellchecker", "class"),
"solr.DirectSolrSpellChecker", "solr.DirectSolrSpellChecker",
@ -449,16 +449,16 @@ public class TestSolrConfigHandler extends RestTestBase {
" {name: s2,lookupImpl: FuzzyLookupFactory , dictionaryImpl : DocumentExpressionDictionaryFactory}]" + " {name: s2,lookupImpl: FuzzyLookupFactory , dictionaryImpl : DocumentExpressionDictionaryFactory}]" +
" }\n" + " }\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
map = testForResponseElement(writeHarness, map = testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config?wt=json", "/config",
cloudSolrClient, cloudSolrClient,
Arrays.asList("config", "requestHandler","/dump100", "class"), Arrays.asList("config", "requestHandler","/dump100", "class"),
"org.apache.solr.handler.DumpRequestHandler", "org.apache.solr.handler.DumpRequestHandler",
10); 10);
map = getRespMap("/dump100?wt=json&json.nl=arrmap&initArgs=true", writeHarness); map = getRespMap("/dump100?json.nl=arrmap&initArgs=true", writeHarness);
List initArgs = (List) map.get("initArgs"); List initArgs = (List) map.get("initArgs");
assertNotNull(initArgs); assertNotNull(initArgs);
assertTrue(initArgs.size() >= 2); assertTrue(initArgs.size() >= 2);
@ -471,11 +471,11 @@ public class TestSolrConfigHandler extends RestTestBase {
" registerPath :'/solr,/v2'"+ " registerPath :'/solr,/v2'"+
", 'startup' : 'lazy'}\n" + ", 'startup' : 'lazy'}\n" +
"}"; "}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
testForResponseElement(writeHarness, testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config/overlay?wt=json", "/config/overlay",
cloudSolrClient, cloudSolrClient,
Arrays.asList("overlay", "requestHandler", "/dump101", "startup"), Arrays.asList("overlay", "requestHandler", "/dump101", "startup"),
"lazy", "lazy",
@ -484,18 +484,18 @@ public class TestSolrConfigHandler extends RestTestBase {
payload = "{\n" + payload = "{\n" +
"'add-cache' : {name:'lfuCacheDecayFalse', class:'solr.search.LFUCache', size:10 ,initialSize:9 , timeDecay:false }," + "'add-cache' : {name:'lfuCacheDecayFalse', class:'solr.search.LFUCache', size:10 ,initialSize:9 , timeDecay:false }," +
"'add-cache' : {name: 'perSegFilter', class: 'solr.search.LRUCache', size:10, initialSize:0 , autowarmCount:10}}"; "'add-cache' : {name: 'perSegFilter', class: 'solr.search.LRUCache', size:10, initialSize:0 , autowarmCount:10}}";
runConfigCommand(writeHarness, "/config?wt=json", payload); runConfigCommand(writeHarness, "/config", payload);
map = testForResponseElement(writeHarness, map = testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config/overlay?wt=json", "/config/overlay",
cloudSolrClient, cloudSolrClient,
Arrays.asList("overlay", "cache", "lfuCacheDecayFalse", "class"), Arrays.asList("overlay", "cache", "lfuCacheDecayFalse", "class"),
"solr.search.LFUCache", "solr.search.LFUCache",
10); 10);
assertEquals("solr.search.LRUCache",getObjectByPath(map, true, ImmutableList.of("overlay", "cache", "perSegFilter", "class"))); assertEquals("solr.search.LRUCache",getObjectByPath(map, true, ImmutableList.of("overlay", "cache", "perSegFilter", "class")));
map = getRespMap("/dump101?cacheNames=lfuCacheDecayFalse&cacheNames=perSegFilter&wt=json", writeHarness); map = getRespMap("/dump101?cacheNames=lfuCacheDecayFalse&cacheNames=perSegFilter", writeHarness);
assertEquals("Actual output "+ Utils.toJSONString(map), "org.apache.solr.search.LRUCache",getObjectByPath(map, true, ImmutableList.of( "caches", "perSegFilter"))); assertEquals("Actual output "+ Utils.toJSONString(map), "org.apache.solr.search.LRUCache",getObjectByPath(map, true, ImmutableList.of( "caches", "perSegFilter")));
assertEquals("Actual output "+ Utils.toJSONString(map), "org.apache.solr.search.LFUCache",getObjectByPath(map, true, ImmutableList.of( "caches", "lfuCacheDecayFalse"))); assertEquals("Actual output "+ Utils.toJSONString(map), "org.apache.solr.search.LFUCache",getObjectByPath(map, true, ImmutableList.of( "caches", "lfuCacheDecayFalse")));
@ -569,12 +569,12 @@ public class TestSolrConfigHandler extends RestTestBase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(harness, "/config/params", payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/params?wt=json", "/config/params",
null, null,
Arrays.asList("response", "params", "x", "a"), Arrays.asList("response", "params", "x", "a"),
"A val", "A val",
@ -583,7 +583,7 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/params?wt=json", "/config/params",
null, null,
Arrays.asList("response", "params", "x", "b"), Arrays.asList("response", "params", "x", "b"),
"B val", "B val",
@ -593,12 +593,12 @@ public class TestSolrConfigHandler extends RestTestBase {
"'create-requesthandler' : { 'name' : '/d', registerPath :'/solr,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" + "'create-requesthandler' : { 'name' : '/d', registerPath :'/solr,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
"}"; "}";
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(harness, "/config", payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "requestHandler", "/d", "name"), Arrays.asList("overlay", "requestHandler", "/d", "name"),
"/d", "/d",
@ -606,14 +606,14 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement(harness, TestSolrConfigHandler.testForResponseElement(harness,
null, null,
"/d?wt=json&useParams=x", "/d?useParams=x",
null, null,
Arrays.asList("params", "a"), Arrays.asList("params", "a"),
"A val", "A val",
5); 5);
TestSolrConfigHandler.testForResponseElement(harness, TestSolrConfigHandler.testForResponseElement(harness,
null, null,
"/d?wt=json&useParams=x&a=fomrequest", "/d?useParams=x&a=fomrequest",
null, null,
Arrays.asList("params", "a"), Arrays.asList("params", "a"),
"fomrequest", "fomrequest",
@ -623,11 +623,11 @@ public class TestSolrConfigHandler extends RestTestBase {
"'create-requesthandler' : { 'name' : '/dump1', registerPath :'/solr,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" + "'create-requesthandler' : { 'name' : '/dump1', registerPath :'/solr,/v2' , 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" +
"}"; "}";
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(harness, "/config", payload);
TestSolrConfigHandler.testForResponseElement(harness, TestSolrConfigHandler.testForResponseElement(harness,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "requestHandler", "/dump1", "name"), Arrays.asList("overlay", "requestHandler", "/dump1", "name"),
"/dump1", "/dump1",
@ -636,7 +636,7 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/dump1?wt=json", "/dump1",
null, null,
Arrays.asList("params", "a"), Arrays.asList("params", "a"),
"A val", "A val",
@ -652,12 +652,12 @@ public class TestSolrConfigHandler extends RestTestBase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(harness, "/config/params", payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/params?wt=json", "/config/params",
null, null,
Arrays.asList("response", "params", "y", "c"), Arrays.asList("response", "params", "y", "c"),
"CY val", "CY val",
@ -665,7 +665,7 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement(harness, TestSolrConfigHandler.testForResponseElement(harness,
null, null,
"/dump1?wt=json&useParams=y", "/dump1?useParams=y",
null, null,
Arrays.asList("params", "c"), Arrays.asList("params", "c"),
"CY val", "CY val",
@ -675,7 +675,7 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/dump1?wt=json&useParams=y", "/dump1?useParams=y",
null, null,
Arrays.asList("params", "b"), Arrays.asList("params", "b"),
"BY val", "BY val",
@ -684,7 +684,7 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/dump1?wt=json&useParams=y", "/dump1?useParams=y",
null, null,
Arrays.asList("params", "a"), Arrays.asList("params", "a"),
"A val", "A val",
@ -693,7 +693,7 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/dump1?wt=json&useParams=y", "/dump1?useParams=y",
null, null,
Arrays.asList("params", "d"), Arrays.asList("params", "d"),
Arrays.asList("val 1", "val 2"), Arrays.asList("val 1", "val 2"),
@ -709,12 +709,12 @@ public class TestSolrConfigHandler extends RestTestBase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(harness, "/config/params", payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/params?wt=json", "/config/params",
null, null,
Arrays.asList("response", "params", "y", "c"), Arrays.asList("response", "params", "y", "c"),
"CY val modified", "CY val modified",
@ -723,7 +723,7 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/params?wt=json", "/config/params",
null, null,
Arrays.asList("response", "params", "y", "e"), Arrays.asList("response", "params", "y", "e"),
"EY val", "EY val",
@ -738,11 +738,11 @@ public class TestSolrConfigHandler extends RestTestBase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(harness, "/config/params", payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/params?wt=json", "/config/params",
null, null,
Arrays.asList("response", "params", "y", "p"), Arrays.asList("response", "params", "y", "p"),
"P val", "P val",
@ -751,17 +751,17 @@ public class TestSolrConfigHandler extends RestTestBase {
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/params?wt=json", "/config/params",
null, null,
Arrays.asList("response", "params", "y", "c"), Arrays.asList("response", "params", "y", "c"),
null, null,
10); 10);
payload = " {'delete' : 'y'}"; payload = " {'delete' : 'y'}";
TestSolrConfigHandler.runConfigCommand(harness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(harness, "/config/params", payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
harness, harness,
null, null,
"/config/params?wt=json", "/config/params",
null, null,
Arrays.asList("response", "params", "y", "p"), Arrays.asList("response", "params", "y", "p"),
null, null,
@ -786,10 +786,10 @@ public class TestSolrConfigHandler extends RestTestBase {
" }\n" + " }\n" +
"}"; "}";
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(harness, "/config", payload);
TestSolrConfigHandler.testForResponseElement(harness, TestSolrConfigHandler.testForResponseElement(harness,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "requestHandler", "aRequestHandler", "class"), Arrays.asList("overlay", "requestHandler", "aRequestHandler", "class"),
"org.apache.solr.handler.DumpRequestHandler", "org.apache.solr.handler.DumpRequestHandler",

View File

@ -46,7 +46,7 @@ public class CheckBackupStatus extends SolrTestCaseJ4 {
} }
public void fetchStatus() throws IOException { public void fetchStatus() throws IOException {
String masterUrl = client.getBaseURL() + "/" + coreName + ReplicationHandler.PATH + "?command=" + ReplicationHandler.CMD_DETAILS; String masterUrl = client.getBaseURL() + "/" + coreName + ReplicationHandler.PATH + "?wt=xml&command=" + ReplicationHandler.CMD_DETAILS;
response = client.getHttpClient().execute(new HttpGet(masterUrl), new BasicResponseHandler()); response = client.getHttpClient().execute(new HttpGet(masterUrl), new BasicResponseHandler());
if(pException.matcher(response).find()) { if(pException.matcher(response).find()) {
fail("Failed to create backup"); fail("Failed to create backup");

View File

@ -121,7 +121,7 @@ public class TestConfigReload extends AbstractFullDistribZkTestBase {
while ( TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutSeconds){ while ( TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutSeconds){
Thread.sleep(50); Thread.sleep(50);
for (String url : urls) { for (String url : urls) {
Map respMap = getAsMap(url+uri+"?wt=json"); Map respMap = getAsMap(url+uri);
if(String.valueOf(newVersion).equals(String.valueOf( getObjectByPath(respMap, true, asList(name, "znodeVersion"))))){ if(String.valueOf(newVersion).equals(String.valueOf( getObjectByPath(respMap, true, asList(name, "znodeVersion"))))){
succeeded.add(url); succeeded.add(url);
} }

View File

@ -267,7 +267,7 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {
public static void runBackupCommand(JettySolrRunner masterJetty, String cmd, String params) throws IOException { public static void runBackupCommand(JettySolrRunner masterJetty, String cmd, String params) throws IOException {
String masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME String masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME
+ ReplicationHandler.PATH+"?command=" + cmd + params; + ReplicationHandler.PATH+"?wt=xml&command=" + cmd + params;
InputStream stream = null; InputStream stream = null;
try { try {
URL url = new URL(masterUrl); URL url = new URL(masterUrl);
@ -290,7 +290,7 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {
} }
public boolean fetchStatus() throws IOException { public boolean fetchStatus() throws IOException {
String masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME + ReplicationHandler.PATH + "?command=" + ReplicationHandler.CMD_DETAILS; String masterUrl = buildUrl(masterJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME + ReplicationHandler.PATH + "?wt=xml&command=" + ReplicationHandler.CMD_DETAILS;
URL url; URL url;
InputStream stream = null; InputStream stream = null;
try { try {

View File

@ -94,12 +94,12 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
"'create-requesthandler' : { 'name' : '/dump0', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" + "'create-requesthandler' : { 'name' : '/dump0', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
"}"; "}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config", payload);
payload = "{\n" + payload = "{\n" +
"'create-requesthandler' : { 'name' : '/dump1', 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" + "'create-requesthandler' : { 'name' : '/dump1', 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" +
"}"; "}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config", payload);
AbstractFullDistribZkTestBase.waitForRecoveriesToFinish(COLL_NAME, cloudClient.getZkStateReader(), false, true, 90); AbstractFullDistribZkTestBase.waitForRecoveriesToFinish(COLL_NAME, cloudClient.getZkStateReader(), false, true, 90);
@ -110,11 +110,11 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
" }\n" + " }\n" +
" }"; " }";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params", payload);
Map result = TestSolrConfigHandler.testForResponseElement(null, Map result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "x", "a"), asList("response", "params", "x", "a"),
"A val", "A val",
@ -123,7 +123,7 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
TestSolrConfigHandler.testForResponseElement(null, TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/overlay?wt=json", "/config/overlay",
cloudClient, cloudClient,
asList("overlay", "requestHandler", "/dump0", "name"), asList("overlay", "requestHandler", "/dump0", "name"),
"/dump0", "/dump0",
@ -131,7 +131,7 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump0?wt=json&useParams=x", "/dump0?useParams=x",
cloudClient, cloudClient,
asList("params", "a"), asList("params", "a"),
"A val", "A val",
@ -140,7 +140,7 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
TestSolrConfigHandler.testForResponseElement(null, TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump0?wt=json&useParams=x&a=fomrequest", "/dump0?useParams=x&a=fomrequest",
cloudClient, cloudClient,
asList("params", "a"), asList("params", "a"),
"fomrequest", "fomrequest",
@ -148,7 +148,7 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/overlay?wt=json", "/config/overlay",
cloudClient, cloudClient,
asList("overlay", "requestHandler", "/dump1", "name"), asList("overlay", "requestHandler", "/dump1", "name"),
"/dump1", "/dump1",
@ -156,7 +156,7 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump1?wt=json", "/dump1",
cloudClient, cloudClient,
asList("params", "a"), asList("params", "a"),
"A val", "A val",
@ -174,12 +174,12 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params", payload);
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "y", "c"), asList("response", "params", "y", "c"),
"CY val", "CY val",
@ -190,7 +190,7 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump1?wt=json&useParams=y", "/dump1?useParams=y",
cloudClient, cloudClient,
asList("params", "c"), asList("params", "c"),
"CY val", "CY val",
@ -202,7 +202,7 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/requestHandler?componentName=/dump1&expandParams=true&wt=json&useParams=y&c=CC", "/config/requestHandler?componentName=/dump1&expandParams=true&useParams=y&c=CC",
cloudClient, cloudClient,
asList("config", "requestHandler","/dump1","_useParamsExpanded_","x", "a"), asList("config", "requestHandler","/dump1","_useParamsExpanded_","x", "a"),
"A val", "A val",
@ -224,12 +224,12 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params", payload);
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "y", "c"), asList("response", "params", "y", "c"),
"CY val modified", "CY val modified",
@ -246,11 +246,11 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params", payload);
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "y", "p"), asList("response", "params", "y", "p"),
"P val", "P val",
@ -260,12 +260,12 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
compareValues(result, 0l, asList("response", "params", "x", "","v")); compareValues(result, 0l, asList("response", "params", "x", "","v"));
payload = "{update :{x : {_appends_ :{ add : 'first' }, _invariants_ : {fixed: f }}}}"; payload = "{update :{x : {_appends_ :{ add : 'first' }, _invariants_ : {fixed: f }}}}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params", payload);
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "x", "_appends_", "add"), asList("response", "params", "x", "_appends_", "add"),
"first", "first",
@ -275,7 +275,7 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump1?wt=json&fixed=changeit&add=second", "/dump1?fixed=changeit&add=second",
cloudClient, cloudClient,
asList("params", "fixed"), asList("params", "fixed"),
"f", "f",
@ -289,11 +289,11 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
}, asList("params", "add")); }, asList("params", "add"));
payload = " {'delete' : 'y'}"; payload = " {'delete' : 'y'}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params", payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "y", "p"), asList("response", "params", "y", "p"),
null, null,

View File

@ -222,7 +222,7 @@ public class TestRestoreCore extends SolrJettyTestBase {
public static boolean fetchRestoreStatus (String baseUrl, String coreName) throws IOException { public static boolean fetchRestoreStatus (String baseUrl, String coreName) throws IOException {
String masterUrl = baseUrl + "/" + coreName + String masterUrl = baseUrl + "/" + coreName +
ReplicationHandler.PATH + "?command=" + ReplicationHandler.CMD_RESTORE_STATUS; ReplicationHandler.PATH + "?wt=xml&command=" + ReplicationHandler.CMD_RESTORE_STATUS;
final Pattern pException = Pattern.compile("<str name=\"exception\">(.*?)</str>"); final Pattern pException = Pattern.compile("<str name=\"exception\">(.*?)</str>");
InputStream stream = null; InputStream stream = null;

View File

@ -2554,12 +2554,13 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
public void assertResponseContains(SolrClient server, SolrParams requestParams, String json) throws IOException, SolrServerException { public void assertResponseContains(SolrClient server, SolrParams requestParams, String json) throws IOException, SolrServerException {
String p = requestParams.get("qt"); String p = requestParams.get("qt");
if(p != null) {
ModifiableSolrParams modifiableSolrParams = (ModifiableSolrParams) requestParams; ModifiableSolrParams modifiableSolrParams = (ModifiableSolrParams) requestParams;
modifiableSolrParams.set("indent", modifiableSolrParams.get("indent", "off"));
if(p != null) {
modifiableSolrParams.remove("qt"); modifiableSolrParams.remove("qt");
} }
QueryRequest query = new QueryRequest( requestParams ); QueryRequest query = new QueryRequest( modifiableSolrParams );
query.setPath(p); query.setPath(p);
query.setResponseParser(new InputStreamResponseParser("json")); query.setResponseParser(new InputStreamResponseParser("json"));
query.setMethod(SolrRequest.METHOD.POST); query.setMethod(SolrRequest.METHOD.POST);

View File

@ -76,12 +76,12 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
"'create-requesthandler' : { 'name' : '/admin/luke', " + "'create-requesthandler' : { 'name' : '/admin/luke', " +
"'class': 'org.apache.solr.handler.DumpRequestHandler'}}"; "'class': 'org.apache.solr.handler.DumpRequestHandler'}}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config", payload);
TestSolrConfigHandler.testForResponseElement(writeHarness, TestSolrConfigHandler.testForResponseElement(writeHarness,
testServerBaseUrl, testServerBaseUrl,
"/config/overlay?wt=json", "/config/overlay",
cloudClient, cloudClient,
Arrays.asList("overlay", "requestHandler", "/admin/luke", "class"), Arrays.asList("overlay", "requestHandler", "/admin/luke", "class"),
"org.apache.solr.handler.DumpRequestHandler", "org.apache.solr.handler.DumpRequestHandler",
@ -124,11 +124,11 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params", payload);
Map result = TestSolrConfigHandler.testForResponseElement(null, Map result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "x", "a"), asList("response", "params", "x", "a"),
"A val", "A val",
@ -139,11 +139,11 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
"'update-requesthandler' : { 'name' : '/dump', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" + "'update-requesthandler' : { 'name' : '/dump', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
"}"; "}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness, "/config", payload);
TestSolrConfigHandler.testForResponseElement(null, TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/overlay?wt=json", "/config/overlay",
cloudClient, cloudClient,
asList("overlay", "requestHandler", "/dump", "name"), asList("overlay", "requestHandler", "/dump", "name"),
"/dump", "/dump",
@ -151,7 +151,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump?wt=json&useParams=x", "/dump?useParams=x",
cloudClient, cloudClient,
asList("params", "a"), asList("params", "a"),
"A val", "A val",
@ -160,7 +160,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
TestSolrConfigHandler.testForResponseElement(null, TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump?wt=json&useParams=x&a=fomrequest", "/dump?useParams=x&a=fomrequest",
cloudClient, cloudClient,
asList("params", "a"), asList("params", "a"),
"fomrequest", "fomrequest",
@ -170,11 +170,11 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
"'create-requesthandler' : { 'name' : '/dump1', 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" + "'create-requesthandler' : { 'name' : '/dump1', 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" +
"}"; "}";
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness,"/config", payload);
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/overlay?wt=json", "/config/overlay",
cloudClient, cloudClient,
asList("overlay", "requestHandler", "/dump1", "name"), asList("overlay", "requestHandler", "/dump1", "name"),
"/dump1", "/dump1",
@ -182,7 +182,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump1?wt=json", "/dump1",
cloudClient, cloudClient,
asList("params", "a"), asList("params", "a"),
"A val", "A val",
@ -201,12 +201,12 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params", payload);
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "y", "c"), asList("response", "params", "y", "c"),
"CY val", "CY val",
@ -216,7 +216,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
result = TestSolrConfigHandler.testForResponseElement(null, result = TestSolrConfigHandler.testForResponseElement(null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/dump?wt=json&useParams=y", "/dump?useParams=y",
cloudClient, cloudClient,
asList("params", "c"), asList("params", "c"),
"CY val", "CY val",
@ -235,12 +235,12 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params", payload);
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "y", "c"), asList("response", "params", "y", "c"),
"CY val modified", "CY val modified",
@ -257,11 +257,11 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
" }"; " }";
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params", payload);
result = TestSolrConfigHandler.testForResponseElement( result = TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "y", "p"), asList("response", "params", "y", "p"),
"P val", "P val",
@ -269,11 +269,11 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
compareValues(result, null, asList("response", "params", "y", "c")); compareValues(result, null, asList("response", "params", "y", "c"));
payload = " {'delete' : 'y'}"; payload = " {'delete' : 'y'}";
TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params?wt=json", payload); TestSolrConfigHandler.runConfigCommand(writeHarness,"/config/params", payload);
TestSolrConfigHandler.testForResponseElement( TestSolrConfigHandler.testForResponseElement(
null, null,
urls.get(random().nextInt(urls.size())), urls.get(random().nextInt(urls.size())),
"/config/params?wt=json", "/config/params",
cloudClient, cloudClient,
asList("response", "params", "y", "p"), asList("response", "params", "y", "p"),
null, null,

View File

@ -143,7 +143,7 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
val3 = String.valueOf(10 * i + 3); val3 = String.valueOf(10 * i + 3);
payload = payload.replace("CACHEVAL3", val3); payload = payload.replace("CACHEVAL3", val3);
response = publisher.post("/config?wt=json", SolrTestCaseJ4.json(payload)); response = publisher.post("/config", SolrTestCaseJ4.json(payload));
} finally { } finally {
publisher.close(); publisher.close();
} }
@ -171,7 +171,7 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
while ( TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutSeconds) { while ( TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutSeconds) {
Thread.sleep(100); Thread.sleep(100);
errmessages.clear(); errmessages.clear();
Map respMap = getAsMap(url+"/config/overlay?wt=json", cloudClient); Map respMap = getAsMap(url+"/config/overlay", cloudClient);
Map m = (Map) respMap.get("overlay"); Map m = (Map) respMap.get("overlay");
if(m!= null) m = (Map) m.get("props"); if(m!= null) m = (Map) m.get("props");
if(m == null) { if(m == null) {

View File

@ -51,7 +51,7 @@ public class JSONWriterTest extends SolrTestCaseJ4 {
@Test @Test
public void testTypes() throws IOException { public void testTypes() throws IOException {
SolrQueryRequest req = req("dummy"); SolrQueryRequest req = req("q", "dummy", "indent","off");
SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryResponse rsp = new SolrQueryResponse();
QueryResponseWriter w = new PythonResponseWriter(); QueryResponseWriter w = new PythonResponseWriter();
@ -90,7 +90,7 @@ public class JSONWriterTest extends SolrTestCaseJ4 {
} }
private void implTestJSON(final String namedListStyle) throws IOException { private void implTestJSON(final String namedListStyle) throws IOException {
SolrQueryRequest req = req("wt","json","json.nl",namedListStyle); SolrQueryRequest req = req("wt","json","json.nl",namedListStyle, "indent", "off");
SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryResponse rsp = new SolrQueryResponse();
JSONResponseWriter w = new JSONResponseWriter(); JSONResponseWriter w = new JSONResponseWriter();

View File

@ -138,7 +138,12 @@ public class TestRawResponseWriter extends SolrTestCaseJ4 {
// check response against each writer // check response against each writer
// xml & none (default behavior same as XML) // xml & none (default behavior same as XML)
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n<str name=\"content\">test</str><str name=\"foo\">bar</str>\n</response>\n"; String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<response>\n" +
"\n" +
"<str name=\"content\">test</str>\n" +
"<str name=\"foo\">bar</str>\n" +
"</response>\n";
StringWriter xmlSout = new StringWriter(); StringWriter xmlSout = new StringWriter();
writerXmlBase.write(xmlSout, req(), rsp); writerXmlBase.write(xmlSout, req(), rsp);
assertEquals(xml, xmlSout.toString()); assertEquals(xml, xmlSout.toString());
@ -154,7 +159,9 @@ public class TestRawResponseWriter extends SolrTestCaseJ4 {
assertEquals(xml, noneBout.toString(StandardCharsets.UTF_8.toString())); assertEquals(xml, noneBout.toString(StandardCharsets.UTF_8.toString()));
// json // json
String json = "{\"content\":\"test\",\"foo\":\"bar\"}\n"; String json = "{\n" +
" \"content\":\"test\",\n" +
" \"foo\":\"bar\"}\n";
StringWriter jsonSout = new StringWriter(); StringWriter jsonSout = new StringWriter();
writerJsonBase.write(jsonSout, req(), rsp); writerJsonBase.write(jsonSout, req(), rsp);
assertEquals(json, jsonSout.toString()); assertEquals(json, jsonSout.toString());

View File

@ -107,7 +107,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
" }"; " }";
String response = restTestHarness.post("/schema?wt=json", json(payload)); String response = restTestHarness.post("/schema", json(payload));
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
List l = (List) map.get("errors"); List l = (List) map.get("errors");
assertNotNull("No errors", l); assertNotNull("No errors", l);
@ -142,7 +142,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n"+ " }\n"+
"}}"; "}}";
String response = restTestHarness.post("/schema?wt=json", String response = restTestHarness.post("/schema",
json(addFieldTypeAnalyzerWithClass + ',' + charFilters + tokenizer + filters + suffix)); json(addFieldTypeAnalyzerWithClass + ',' + charFilters + tokenizer + filters + suffix));
Map map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
List list = (List)map.get("errors"); List list = (List)map.get("errors");
@ -151,7 +151,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertTrue (((String)errorList.get(0)).contains assertTrue (((String)errorList.get(0)).contains
("An analyzer with a class property may not define any char filters!")); ("An analyzer with a class property may not define any char filters!"));
response = restTestHarness.post("/schema?wt=json", response = restTestHarness.post("/schema",
json(addFieldTypeAnalyzerWithClass + ',' + tokenizer + filters + suffix)); json(addFieldTypeAnalyzerWithClass + ',' + tokenizer + filters + suffix));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
list = (List)map.get("errors"); list = (List)map.get("errors");
@ -160,7 +160,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertTrue (((String)errorList.get(0)).contains assertTrue (((String)errorList.get(0)).contains
("An analyzer with a class property may not define a tokenizer!")); ("An analyzer with a class property may not define a tokenizer!"));
response = restTestHarness.post("/schema?wt=json", response = restTestHarness.post("/schema",
json(addFieldTypeAnalyzerWithClass + ',' + filters + suffix)); json(addFieldTypeAnalyzerWithClass + ',' + filters + suffix));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
list = (List)map.get("errors"); list = (List)map.get("errors");
@ -169,7 +169,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertTrue (((String)errorList.get(0)).contains assertTrue (((String)errorList.get(0)).contains
("An analyzer with a class property may not define any filters!")); ("An analyzer with a class property may not define any filters!"));
response = restTestHarness.post("/schema?wt=json", json(addFieldTypeAnalyzerWithClass + suffix)); response = restTestHarness.post("/schema", json(addFieldTypeAnalyzerWithClass + suffix));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, map.get("errors")); assertNull(response, map.get("errors"));
@ -203,7 +203,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
" }"; " }";
String response = harness.post("/schema?wt=json", json(payload)); String response = harness.post("/schema", json(payload));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, map.get("errors")); assertNull(response, map.get("errors"));
@ -226,7 +226,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
" }"; " }";
String response = harness.post("/schema?wt=json", json(payload)); String response = harness.post("/schema", json(payload));
Map map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNotNull(response, map.get("errors")); assertNotNull(response, map.get("errors"));
@ -249,7 +249,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
"}"; "}";
String response = harness.post("/schema?wt=json", json(payload)); String response = harness.post("/schema", json(payload));
Map map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNotNull(response, map.get("errors")); assertNotNull(response, map.get("errors"));
@ -271,7 +271,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
"}"; "}";
response = harness.post("/schema?wt=json", json(payload)); response = harness.post("/schema", json(payload));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNotNull(response, map.get("errors")); assertNotNull(response, map.get("errors"));
} }
@ -302,7 +302,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
"}"; "}";
String response = harness.post("/schema?wt=json", json(payload)); String response = harness.post("/schema", json(payload));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, map.get("errors")); assertNull(response, map.get("errors"));
@ -319,7 +319,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
" }"; " }";
response = harness.post("/schema?wt=json", json(payload)); response = harness.post("/schema", json(payload));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, map.get("errors")); assertNull(response, map.get("errors"));
@ -499,7 +499,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
" }\n"; " }\n";
String response = harness.post("/schema?wt=json", json(payload)); String response = harness.post("/schema", json(payload));
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, map.get("errors")); assertNull(response, map.get("errors"));
@ -636,7 +636,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" {'source':'NewField4', 'dest':['NewField1'], maxChars: 3333 }]\n" + " {'source':'NewField4', 'dest':['NewField1'], maxChars: 3333 }]\n" +
"}\n"; "}\n";
String response = harness.post("/schema?wt=json", json(cmds)); String response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, map.get("errors")); assertNull(response, map.get("errors"));
@ -691,14 +691,14 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertNull(map.get("NewField3")); assertNull(map.get("NewField3"));
cmds = "{'delete-field-type' : {'name':'NewFieldType'}}"; cmds = "{'delete-field-type' : {'name':'NewFieldType'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
Object errors = map.get("errors"); Object errors = map.get("errors");
assertNotNull(errors); assertNotNull(errors);
assertTrue(errors.toString().contains("Can't delete 'NewFieldType' because it's the field type of ")); assertTrue(errors.toString().contains("Can't delete 'NewFieldType' because it's the field type of "));
cmds = "{'delete-field' : {'name':'NewField1'}}"; cmds = "{'delete-field' : {'name':'NewField1'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
errors = map.get("errors"); errors = map.get("errors");
assertNotNull(errors); assertNotNull(errors);
@ -706,7 +706,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
("Can't delete field 'NewField1' because it's referred to by at least one copy field directive")); ("Can't delete field 'NewField1' because it's referred to by at least one copy field directive"));
cmds = "{'delete-field' : {'name':'NewField2'}}"; cmds = "{'delete-field' : {'name':'NewField2'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
errors = map.get("errors"); errors = map.get("errors");
assertNotNull(errors); assertNotNull(errors);
@ -714,7 +714,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
("Can't delete field 'NewField2' because it's referred to by at least one copy field directive")); ("Can't delete field 'NewField2' because it's referred to by at least one copy field directive"));
cmds = "{'replace-field' : {'name':'NewField1', 'type':'string'}}"; cmds = "{'replace-field' : {'name':'NewField1', 'type':'string'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(map.get("errors")); assertNull(map.get("errors"));
// Make sure the copy field directives with source NewField1 are preserved // Make sure the copy field directives with source NewField1 are preserved
@ -728,7 +728,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertTrue(set.contains("NewDynamicField1A")); assertTrue(set.contains("NewDynamicField1A"));
cmds = "{'delete-dynamic-field' : {'name':'NewDynamicField1*'}}"; cmds = "{'delete-dynamic-field' : {'name':'NewDynamicField1*'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
errors = map.get("errors"); errors = map.get("errors");
assertNotNull(errors); assertNotNull(errors);
@ -736,7 +736,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
("copyField dest :'NewDynamicField1A' is not an explicit field and doesn't match a dynamicField.")); ("copyField dest :'NewDynamicField1A' is not an explicit field and doesn't match a dynamicField."));
cmds = "{'replace-field' : {'name':'NewField2', 'type':'string'}}"; cmds = "{'replace-field' : {'name':'NewField2', 'type':'string'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
errors = map.get("errors"); errors = map.get("errors");
assertNull(errors); assertNull(errors);
@ -753,7 +753,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertTrue(set.contains("NewDynamicField2*")); assertTrue(set.contains("NewDynamicField2*"));
cmds = "{'replace-dynamic-field' : {'name':'NewDynamicField2*', 'type':'string'}}"; cmds = "{'replace-dynamic-field' : {'name':'NewDynamicField2*', 'type':'string'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
errors = map.get("errors"); errors = map.get("errors");
assertNull(errors); assertNull(errors);
@ -763,7 +763,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertEquals("NewField2", ((Map) list.get(0)).get("dest")); assertEquals("NewField2", ((Map) list.get(0)).get("dest"));
cmds = "{'replace-dynamic-field' : {'name':'NewDynamicField1*', 'type':'string'}}"; cmds = "{'replace-dynamic-field' : {'name':'NewDynamicField1*', 'type':'string'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
errors = map.get("errors"); errors = map.get("errors");
assertNull(errors); assertNull(errors);
@ -773,7 +773,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertEquals("NewField1", ((Map) list.get(0)).get("source")); assertEquals("NewField1", ((Map) list.get(0)).get("source"));
cmds = "{'replace-field-type': {'name':'NewFieldType', 'class':'solr.BinaryField'}}"; cmds = "{'replace-field-type': {'name':'NewFieldType', 'class':'solr.BinaryField'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(map.get("errors")); assertNull(map.get("errors"));
// Make sure the copy field directives with sources and destinations of type NewFieldType are preserved // Make sure the copy field directives with sources and destinations of type NewFieldType are preserved
@ -793,7 +793,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" {'source':'NewDynamicField3*', 'dest':'NewField3' },\n" + " {'source':'NewDynamicField3*', 'dest':'NewField3' },\n" +
" {'source':'NewField4', 'dest':['NewField1', 'NewField2', 'NewField3']}]\n" + " {'source':'NewField4', 'dest':['NewField1', 'NewField2', 'NewField3']}]\n" +
"}\n"; "}\n";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(map.get("errors")); assertNull(map.get("errors"));
list = getSourceCopyFields(harness, "NewField1"); list = getSourceCopyFields(harness, "NewField1");
@ -808,7 +808,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
assertEquals(0, list.size()); assertEquals(0, list.size());
cmds = "{'delete-field': [{'name':'NewField1'},{'name':'NewField2'},{'name':'NewField3'},{'name':'NewField4'}]}"; cmds = "{'delete-field': [{'name':'NewField1'},{'name':'NewField2'},{'name':'NewField3'},{'name':'NewField4'}]}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(map.get("errors")); assertNull(map.get("errors"));
@ -816,12 +816,12 @@ public class TestBulkSchemaAPI extends RestTestBase {
" {'name':'NewDynamicField2*'},\n" + " {'name':'NewDynamicField2*'},\n" +
" {'name':'NewDynamicField3*'}]\n" + " {'name':'NewDynamicField3*'}]\n" +
"}\n"; "}\n";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(map.get("errors")); assertNull(map.get("errors"));
cmds = "{'delete-field-type':{'name':'NewFieldType'}}"; cmds = "{'delete-field-type':{'name':'NewFieldType'}}";
response = harness.post("/schema?wt=json", json(cmds)); response = harness.post("/schema", json(cmds));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(map.get("errors")); assertNull(map.get("errors"));
} }
@ -849,7 +849,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n" + " }\n" +
"}\n"; "}\n";
String response = harness.post("/schema?wt=json&indent=on", json(payload)); String response = harness.post("/schema", json(payload));
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, map.get("errors")); assertNull(response, map.get("errors"));
@ -876,7 +876,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
" }\n"+ " }\n"+
"}\n"; "}\n";
response = harness.post("/schema?wt=json&indent=on", json(payload)); response = harness.post("/schema", json(payload));
map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response))); map = (Map)ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, map.get("errors")); assertNull(response, map.get("errors"));
@ -900,7 +900,7 @@ public class TestBulkSchemaAPI extends RestTestBase {
} }
public static Map getRespMap(RestTestHarness restHarness) throws Exception { public static Map getRespMap(RestTestHarness restHarness) throws Exception {
return getAsMap("/schema?wt=json", restHarness); return getAsMap("/schema", restHarness);
} }
public static Map getAsMap(String uri, RestTestHarness restHarness) throws Exception { public static Map getAsMap(String uri, RestTestHarness restHarness) throws Exception {

View File

@ -20,7 +20,7 @@ import org.junit.Test;
public class TestCopyFieldCollectionResource extends SolrRestletTestBase { public class TestCopyFieldCollectionResource extends SolrRestletTestBase {
@Test @Test
public void testGetAllCopyFields() throws Exception { public void testXMLGetAllCopyFields() throws Exception {
assertQ("/schema/copyfields?indent=on&wt=xml", assertQ("/schema/copyfields?indent=on&wt=xml",
"/response/arr[@name='copyFields']/lst[ str[@name='source'][.='src_sub_no_ast_i']" "/response/arr[@name='copyFields']/lst[ str[@name='source'][.='src_sub_no_ast_i']"
+" and str[@name='dest'][.='title']]", +" and str[@name='dest'][.='title']]",
@ -79,8 +79,8 @@ public class TestCopyFieldCollectionResource extends SolrRestletTestBase {
} }
@Test @Test
public void testJsonGetAllCopyFields() throws Exception { public void testGetAllCopyFields() throws Exception {
assertJQ("/schema/copyfields?indent=on&wt=json", assertJQ("/schema/copyfields",
"/copyFields/[1]=={'source':'src_sub_no_ast_i','dest':'title'}", "/copyFields/[1]=={'source':'src_sub_no_ast_i','dest':'title'}",
"/copyFields/[7]=={'source':'title','dest':'dest_sub_no_ast_s'}", "/copyFields/[7]=={'source':'title','dest':'dest_sub_no_ast_s'}",
@ -102,7 +102,7 @@ public class TestCopyFieldCollectionResource extends SolrRestletTestBase {
@Test @Test
public void testRestrictSource() throws Exception { public void testRestrictSource() throws Exception {
assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=title,*_i,*_src_sub_i,src_sub_no_ast_i", assertQ("/schema/copyfields/?wt=xml&source.fl=title,*_i,*_src_sub_i,src_sub_no_ast_i",
"count(/response/arr[@name='copyFields']/lst) = 16", // 4 + 4 + 4 + 4 "count(/response/arr[@name='copyFields']/lst) = 16", // 4 + 4 + 4 + 4
"count(/response/arr[@name='copyFields']/lst/str[@name='source'][.='title']) = 4", "count(/response/arr[@name='copyFields']/lst/str[@name='source'][.='title']) = 4",
"count(/response/arr[@name='copyFields']/lst/str[@name='source'][.='*_i']) = 4", "count(/response/arr[@name='copyFields']/lst/str[@name='source'][.='*_i']) = 4",
@ -112,7 +112,7 @@ public class TestCopyFieldCollectionResource extends SolrRestletTestBase {
@Test @Test
public void testRestrictDest() throws Exception { public void testRestrictDest() throws Exception {
assertQ("/schema/copyfields/?indent=on&wt=xml&dest.fl=title,*_s,*_dest_sub_s,dest_sub_no_ast_s", assertQ("/schema/copyfields/?wt=xml&dest.fl=title,*_s,*_dest_sub_s,dest_sub_no_ast_s",
"count(/response/arr[@name='copyFields']/lst) = 16", // 3 + 4 + 4 + 5 "count(/response/arr[@name='copyFields']/lst) = 16", // 3 + 4 + 4 + 5
"count(/response/arr[@name='copyFields']/lst/str[@name='dest'][.='title']) = 3", "count(/response/arr[@name='copyFields']/lst/str[@name='dest'][.='title']) = 3",
"count(/response/arr[@name='copyFields']/lst/str[@name='dest'][.='*_s']) = 4", "count(/response/arr[@name='copyFields']/lst/str[@name='dest'][.='*_s']) = 4",
@ -122,7 +122,7 @@ public class TestCopyFieldCollectionResource extends SolrRestletTestBase {
@Test @Test
public void testRestrictSourceAndDest() throws Exception { public void testRestrictSourceAndDest() throws Exception {
assertQ("/schema/copyfields/?indent=on&wt=xml&source.fl=title,*_i&dest.fl=title,dest_sub_no_ast_s", assertQ("/schema/copyfields/?wt=xml&source.fl=title,*_i&dest.fl=title,dest_sub_no_ast_s",
"count(/response/arr[@name='copyFields']/lst) = 3", "count(/response/arr[@name='copyFields']/lst) = 3",
"/response/arr[@name='copyFields']/lst[ str[@name='source'][.='title']" "/response/arr[@name='copyFields']/lst[ str[@name='source'][.='title']"

View File

@ -23,8 +23,8 @@ import org.junit.Test;
public class TestFieldCollectionResource extends SolrRestletTestBase { public class TestFieldCollectionResource extends SolrRestletTestBase {
@Test @Test
public void testGetAllFields() throws Exception { public void testXMLGetAllFields() throws Exception {
assertQ("/schema/fields?indent=on&wt=xml", assertQ("/schema/fields?wt=xml",
"(/response/arr[@name='fields']/lst/str[@name='name'])[1] = 'HTMLstandardtok'", "(/response/arr[@name='fields']/lst/str[@name='name'])[1] = 'HTMLstandardtok'",
"(/response/arr[@name='fields']/lst/str[@name='name'])[2] = 'HTMLwhitetok'", "(/response/arr[@name='fields']/lst/str[@name='name'])[2] = 'HTMLwhitetok'",
"(/response/arr[@name='fields']/lst/str[@name='name'])[3] = '_version_'"); "(/response/arr[@name='fields']/lst/str[@name='name'])[3] = '_version_'");
@ -32,25 +32,25 @@ public class TestFieldCollectionResource extends SolrRestletTestBase {
@Test @Test
public void testJsonGetAllFields() throws Exception { public void testGetAllFields() throws Exception {
assertJQ("/schema/fields?indent=on", assertJQ("/schema/fields",
"/fields/[0]/name=='HTMLstandardtok'", "/fields/[0]/name=='HTMLstandardtok'",
"/fields/[1]/name=='HTMLwhitetok'", "/fields/[1]/name=='HTMLwhitetok'",
"/fields/[2]/name=='_version_'"); "/fields/[2]/name=='_version_'");
} }
@Test @Test
public void testGetThreeFieldsDontIncludeDynamic() throws IOException { public void testXMLGetThreeFieldsDontIncludeDynamic() throws IOException {
// //
assertQ("/schema/fields?indent=on&wt=xml&fl=id,_version_,price_i", assertQ("/schema/fields?wt=xml&fl=id,_version_,price_i",
"count(/response/arr[@name='fields']/lst/str[@name='name']) = 2", "count(/response/arr[@name='fields']/lst/str[@name='name']) = 2",
"(/response/arr[@name='fields']/lst/str[@name='name'])[1] = 'id'", "(/response/arr[@name='fields']/lst/str[@name='name'])[1] = 'id'",
"(/response/arr[@name='fields']/lst/str[@name='name'])[2] = '_version_'"); "(/response/arr[@name='fields']/lst/str[@name='name'])[2] = '_version_'");
} }
@Test @Test
public void testGetThreeFieldsIncludeDynamic() throws IOException { public void testXMLGetThreeFieldsIncludeDynamic() throws IOException {
assertQ("/schema/fields?indent=on&wt=xml&fl=id,_version_,price_i&includeDynamic=on", assertQ("/schema/fields?wt=xml&fl=id,_version_,price_i&includeDynamic=on",
"count(/response/arr[@name='fields']/lst/str[@name='name']) = 3", "count(/response/arr[@name='fields']/lst/str[@name='name']) = 3",
@ -64,16 +64,16 @@ public class TestFieldCollectionResource extends SolrRestletTestBase {
+" and str[@name='dynamicBase']='*_i']"); +" and str[@name='dynamicBase']='*_i']");
} }
@Test @Test
public void testNotFoundFields() throws IOException { public void testXMLNotFoundFields() throws IOException {
assertQ("/schema/fields?indent=on&wt=xml&fl=not_in_there,this_one_either", assertQ("/schema/fields?&wt=xml&fl=not_in_there,this_one_either",
"count(/response/arr[@name='fields']) = 1", "count(/response/arr[@name='fields']) = 1",
"count(/response/arr[@name='fields']/lst/str[@name='name']) = 0"); "count(/response/arr[@name='fields']/lst/str[@name='name']) = 0");
} }
@Test @Test
public void testJsonGetAllFieldsIncludeDynamic() throws Exception { public void testGetAllFieldsIncludeDynamic() throws Exception {
assertJQ("/schema/fields?indent=on&includeDynamic=true", assertJQ("/schema/fields?includeDynamic=true",
"/fields/[0]/name=='HTMLstandardtok'", "/fields/[0]/name=='HTMLstandardtok'",
"/fields/[1]/name=='HTMLwhitetok'", "/fields/[1]/name=='HTMLwhitetok'",
"/fields/[2]/name=='_version_'", "/fields/[2]/name=='_version_'",

View File

@ -21,10 +21,10 @@ import org.junit.Test;
public class TestFieldTypeResource extends SolrRestletTestBase { public class TestFieldTypeResource extends SolrRestletTestBase {
@Test @Test
public void testGetFieldType() throws Exception { public void testXMLGetFieldType() throws Exception {
final String expectedFloatClass = RANDOMIZED_NUMERIC_FIELDTYPES.get(Float.class); final String expectedFloatClass = RANDOMIZED_NUMERIC_FIELDTYPES.get(Float.class);
final boolean expectedDocValues = Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP); final boolean expectedDocValues = Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP);
assertQ("/schema/fieldtypes/float?indent=on&wt=xml&showDefaults=true", assertQ("/schema/fieldtypes/float?wt=xml&showDefaults=true",
"count(/response/lst[@name='fieldType']) = 1", "count(/response/lst[@name='fieldType']) = 1",
"count(/response/lst[@name='fieldType']/*) = 17", "count(/response/lst[@name='fieldType']/*) = 17",
"/response/lst[@name='fieldType']/str[@name='name'] = 'float'", "/response/lst[@name='fieldType']/str[@name='name'] = 'float'",
@ -46,8 +46,8 @@ public class TestFieldTypeResource extends SolrRestletTestBase {
} }
@Test @Test
public void testGetNotFoundFieldType() throws Exception { public void testXMLGetNotFoundFieldType() throws Exception {
assertQ("/schema/fieldtypes/not_in_there?indent=on&wt=xml", assertQ("/schema/fieldtypes/not_in_there?wt=xml",
"count(/response/lst[@name='fieldtypes']) = 0", "count(/response/lst[@name='fieldtypes']) = 0",
"/response/lst[@name='responseHeader']/int[@name='status'] = '404'", "/response/lst[@name='responseHeader']/int[@name='status'] = '404'",
"/response/lst[@name='error']/int[@name='code'] = '404'"); "/response/lst[@name='error']/int[@name='code'] = '404'");
@ -57,7 +57,7 @@ public class TestFieldTypeResource extends SolrRestletTestBase {
public void testJsonGetFieldType() throws Exception { public void testJsonGetFieldType() throws Exception {
final String expectedFloatClass = RANDOMIZED_NUMERIC_FIELDTYPES.get(Float.class); final String expectedFloatClass = RANDOMIZED_NUMERIC_FIELDTYPES.get(Float.class);
final boolean expectedDocValues = Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP); final boolean expectedDocValues = Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP);
assertJQ("/schema/fieldtypes/float?indent=on&showDefaults=on", // assertJQ will add "&wt=json" assertJQ("/schema/fieldtypes/float?showDefaults=on",
"/fieldType/name=='float'", "/fieldType/name=='float'",
"/fieldType/class=='"+expectedFloatClass+"'", "/fieldType/class=='"+expectedFloatClass+"'",
"/fieldType/precisionStep=='0'", "/fieldType/precisionStep=='0'",
@ -76,8 +76,8 @@ public class TestFieldTypeResource extends SolrRestletTestBase {
} }
@Test @Test
public void testGetFieldTypeDontShowDefaults() throws Exception { public void testXMLGetFieldTypeDontShowDefaults() throws Exception {
assertQ("/schema/fieldtypes/teststop?wt=xml&indent=on", assertQ("/schema/fieldtypes/teststop?wt=xml",
"count(/response/lst[@name='fieldType']/*) = 3", "count(/response/lst[@name='fieldType']/*) = 3",
"/response/lst[@name='fieldType']/str[@name='name'] = 'teststop'", "/response/lst[@name='fieldType']/str[@name='name'] = 'teststop'",
"/response/lst[@name='fieldType']/str[@name='class'] = 'solr.TextField'", "/response/lst[@name='fieldType']/str[@name='class'] = 'solr.TextField'",

View File

@ -21,7 +21,7 @@ import org.junit.Test;
public class TestSchemaNameResource extends SolrRestletTestBase { public class TestSchemaNameResource extends SolrRestletTestBase {
@Test @Test
public void testGetSchemaName() throws Exception { public void testGetSchemaName() throws Exception {
assertQ("/schema/name?indent=on&wt=xml", assertQ("/schema/name?wt=xml",
"count(/response/str[@name='name']) = 1", "count(/response/str[@name='name']) = 1",
"/response/str[@name='name'][.='test-rest']"); "/response/str[@name='name'][.='test-rest']");
} }

View File

@ -103,7 +103,7 @@ public class TestSchemaResource extends SolrRestletTestBase {
@Test @Test
public void testJSONResponse() throws Exception { public void testJSONResponse() throws Exception {
assertJQ("/schema?wt=json", // Should work with or without a trailing slash assertJQ("/schema", // Should work with or without a trailing slash
"/schema/name=='test-rest'", "/schema/name=='test-rest'",
"/schema/version==1.6", "/schema/version==1.6",

View File

@ -27,7 +27,7 @@ public class TestSchemaSimilarityResource extends SolrRestletTestBase {
*/ */
@Test @Test
public void testGetSchemaSimilarity() throws Exception { public void testGetSchemaSimilarity() throws Exception {
assertQ("/schema/similarity?indent=on&wt=xml", assertQ("/schema/similarity?wt=xml",
"count(/response/lst[@name='similarity']) = 1", "count(/response/lst[@name='similarity']) = 1",
"/response/lst[@name='similarity']/str[@name='class'][.='org.apache.solr.search.similarities.SchemaSimilarityFactory']"); "/response/lst[@name='similarity']/str[@name='class'][.='org.apache.solr.search.similarities.SchemaSimilarityFactory']");
} }

View File

@ -149,7 +149,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
payload = payload.replace("myNewFieldTypeName", newFieldTypeName); payload = payload.replace("myNewFieldTypeName", newFieldTypeName);
RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size())); RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
String response = publisher.post("/schema?wt=json", SolrTestCaseJ4.json(payload)); String response = publisher.post("/schema", SolrTestCaseJ4.json(payload));
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
Object errors = map.get("errors"); Object errors = map.get("errors");
if (errors != null) { if (errors != null) {
@ -219,7 +219,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
payload = payload.replace("myNewFieldTypeName", newFieldTypeName); payload = payload.replace("myNewFieldTypeName", newFieldTypeName);
RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size())); RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
String response = publisher.post("/schema?wt=json", SolrTestCaseJ4.json(payload)); String response = publisher.post("/schema", SolrTestCaseJ4.json(payload));
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
Object errors = map.get("errors"); Object errors = map.get("errors");
if (errors != null) { if (errors != null) {
@ -281,7 +281,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
payload = payload.replace("myNewFieldTypeName", newFieldTypeName); payload = payload.replace("myNewFieldTypeName", newFieldTypeName);
RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size())); RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
String response = publisher.post("/schema?wt=json", SolrTestCaseJ4.json(payload)); String response = publisher.post("/schema", SolrTestCaseJ4.json(payload));
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
Object errors = map.get("errors"); Object errors = map.get("errors");
if (errors != null) { if (errors != null) {

View File

@ -88,7 +88,7 @@ public class TestUseDocValuesAsStored2 extends RestTestBase {
" }\n" + " }\n" +
" }\n"; " }\n";
String response = harness.post("/schema?wt=json", json(payload)); String response = harness.post("/schema", json(payload));
Map m = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map m = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertNull(response, m.get("errors")); assertNull(response, m.get("errors"));
@ -140,7 +140,7 @@ public class TestUseDocValuesAsStored2 extends RestTestBase {
" 'docValues':true,\n" + " 'docValues':true,\n" +
" 'indexed':false\n" + " 'indexed':false\n" +
" }}"; " }}";
response = harness.post("/schema?wt=json", json(payload)); response = harness.post("/schema", json(payload));
m = TestBulkSchemaAPI.getObj(harness, "a1", "fields"); m = TestBulkSchemaAPI.getObj(harness, "a1", "fields");
assertNotNull("field a1 doesn't exist any more", m); assertNotNull("field a1 doesn't exist any more", m);
assertEquals(Boolean.FALSE, m.get("useDocValuesAsStored")); assertEquals(Boolean.FALSE, m.get("useDocValuesAsStored"));
@ -155,7 +155,7 @@ public class TestUseDocValuesAsStored2 extends RestTestBase {
" 'docValues':true,\n" + " 'docValues':true,\n" +
" 'indexed':false\n" + " 'indexed':false\n" +
" }}"; " }}";
response = harness.post("/schema?wt=json", json(payload)); response = harness.post("/schema", json(payload));
m = TestBulkSchemaAPI.getObj(harness, "a1", "fields"); m = TestBulkSchemaAPI.getObj(harness, "a1", "fields");
assertNotNull("field a1 doesn't exist any more", m); assertNotNull("field a1 doesn't exist any more", m);
assertEquals(Boolean.TRUE, m.get("useDocValuesAsStored")); assertEquals(Boolean.TRUE, m.get("useDocValuesAsStored"));
@ -169,7 +169,7 @@ public class TestUseDocValuesAsStored2 extends RestTestBase {
" 'docValues':true,\n" + " 'docValues':true,\n" +
" 'indexed':true\n" + " 'indexed':true\n" +
" }}"; " }}";
response = harness.post("/schema?wt=json", json(payload)); response = harness.post("/schema", json(payload));
m = TestBulkSchemaAPI.getObj(harness, "a4", "fields"); m = TestBulkSchemaAPI.getObj(harness, "a4", "fields");
assertNotNull("field a4 not found", m); assertNotNull("field a4 not found", m);
assertEquals(Boolean.TRUE, m.get("useDocValuesAsStored")); assertEquals(Boolean.TRUE, m.get("useDocValuesAsStored"));

View File

@ -84,6 +84,7 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
params.add("fq", "{!hash worker=0 workers=3 cost="+getCost(random)+"}"); params.add("fq", "{!hash worker=0 workers=3 cost="+getCost(random)+"}");
params.add("partitionKeys", "a_s"); params.add("partitionKeys", "a_s");
params.add("rows","50"); params.add("rows","50");
params.add("wt", "xml");
HashSet set1 = new HashSet(); HashSet set1 = new HashSet();
String response = h.query(req(params)); String response = h.query(req(params));
@ -102,6 +103,7 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
params.add("fq", "{!hash worker=1 workers=3 cost="+getCost(random)+"}"); params.add("fq", "{!hash worker=1 workers=3 cost="+getCost(random)+"}");
params.add("partitionKeys", "a_s"); params.add("partitionKeys", "a_s");
params.add("rows","50"); params.add("rows","50");
params.add("wt", "xml");
HashSet set2 = new HashSet(); HashSet set2 = new HashSet();
response = h.query(req(params)); response = h.query(req(params));
@ -121,6 +123,7 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
params.add("fq", "{!hash worker=2 workers=3 cost="+getCost(random)+"}"); params.add("fq", "{!hash worker=2 workers=3 cost="+getCost(random)+"}");
params.add("partitionKeys", "a_s"); params.add("partitionKeys", "a_s");
params.add("rows","50"); params.add("rows","50");
params.add("wt", "xml");
HashSet set3 = new HashSet(); HashSet set3 = new HashSet();
response = h.query(req(params)); response = h.query(req(params));
@ -151,6 +154,7 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
params.add("fq", "{!hash worker=0 workers=2 cost="+getCost(random)+"}"); params.add("fq", "{!hash worker=0 workers=2 cost="+getCost(random)+"}");
params.add("partitionKeys", "a_i"); params.add("partitionKeys", "a_i");
params.add("rows","50"); params.add("rows","50");
params.add("wt", "xml");
set1 = new HashSet(); set1 = new HashSet();
response = h.query(req(params)); response = h.query(req(params));
@ -169,6 +173,7 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
params.add("fq", "{!hash worker=1 workers=2 cost="+getCost(random)+"}"); params.add("fq", "{!hash worker=1 workers=2 cost="+getCost(random)+"}");
params.add("partitionKeys", "a_i"); params.add("partitionKeys", "a_i");
params.add("rows","50"); params.add("rows","50");
params.add("wt", "xml");
set2 = new HashSet(); set2 = new HashSet();
response = h.query(req(params)); response = h.query(req(params));
@ -196,6 +201,7 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
params.add("fq", "{!hash worker=0 workers=2 cost="+getCost(random)+"}"); params.add("fq", "{!hash worker=0 workers=2 cost="+getCost(random)+"}");
params.add("partitionKeys", "a_s, a_i, a_l"); params.add("partitionKeys", "a_s, a_i, a_l");
params.add("rows","50"); params.add("rows","50");
params.add("wt", "xml");
set1 = new HashSet(); set1 = new HashSet();
response = h.query(req(params)); response = h.query(req(params));
@ -214,6 +220,7 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
params.add("fq", "{!hash worker=1 workers=2 cost="+getCost(random)+"}"); params.add("fq", "{!hash worker=1 workers=2 cost="+getCost(random)+"}");
params.add("partitionKeys", "a_s, a_i, a_l"); params.add("partitionKeys", "a_s, a_i, a_l");
params.add("rows","50"); params.add("rows","50");
params.add("wt", "xml");
set2 = new HashSet(); set2 = new HashSet();
response = h.query(req(params)); response = h.query(req(params));

View File

@ -203,7 +203,7 @@ public class BasicAuthIntegrationTest extends SolrCloudTestCase {
executeCommand(baseUrl + authcPrefix, cl, "{set-property : { blockUnknown: true}}", "harry", "HarryIsUberCool"); executeCommand(baseUrl + authcPrefix, cl, "{set-property : { blockUnknown: true}}", "harry", "HarryIsUberCool");
verifySecurityStatus(cl, baseUrl + authcPrefix, "authentication/blockUnknown", "true", 20, "harry", "HarryIsUberCool"); verifySecurityStatus(cl, baseUrl + authcPrefix, "authentication/blockUnknown", "true", 20, "harry", "HarryIsUberCool");
verifySecurityStatus(cl, baseUrl + "/admin/info/key?wt=json", "key", NOT_NULL_PREDICATE, 20); verifySecurityStatus(cl, baseUrl + "/admin/info/key", "key", NOT_NULL_PREDICATE, 20);
String[] toolArgs = new String[]{ String[] toolArgs = new String[]{
"status", "-solr", baseUrl}; "status", "-solr", baseUrl};

View File

@ -120,7 +120,7 @@ public class HttpSolrCallGetCoreTest extends SolrCloudTestCase {
@Override @Override
public String getQueryString() { public String getQueryString() {
return "wt=json&version=2"; return "version=2";
} }
@Override @Override

View File

@ -82,10 +82,10 @@ public class TestNamedUpdateProcessors extends AbstractFullDistribZkTestBase {
"'add-runtimelib' : { 'name' : 'colltest' ,'version':1}\n" + "'add-runtimelib' : { 'name' : 'colltest' ,'version':1}\n" +
"}"; "}";
RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
TestSolrConfigHandler.testForResponseElement(client, TestSolrConfigHandler.testForResponseElement(client,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "runtimeLib", blobName, "version"), Arrays.asList("overlay", "runtimeLib", blobName, "version"),
1l, 10); 1l, 10);
@ -97,11 +97,11 @@ public class TestNamedUpdateProcessors extends AbstractFullDistribZkTestBase {
"}"; "}";
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size())); client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
TestSolrConfigHandler.runConfigCommand(client, "/config?wt=json", payload); TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
for (RestTestHarness restTestHarness : restTestHarnesses) { for (RestTestHarness restTestHarness : restTestHarnesses) {
TestSolrConfigHandler.testForResponseElement(restTestHarness, TestSolrConfigHandler.testForResponseElement(restTestHarness,
null, null,
"/config/overlay?wt=json", "/config/overlay",
null, null,
Arrays.asList("overlay", "updateProcessor", "firstFld", "fieldName"), Arrays.asList("overlay", "updateProcessor", "firstFld", "fieldName"),
"test_s", 10); "test_s", 10);

View File

@ -44,6 +44,9 @@
<lst name="defaults"> <lst name="defaults">
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<str name="df">text</str> <str name="df">text</str>
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
</lst> </lst>
</requestHandler> </requestHandler>

View File

@ -713,6 +713,9 @@
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<int name="rows">10</int> <int name="rows">10</int>
<str name="df">text</str> <str name="df">text</str>
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
</lst> </lst>
<!-- In addition to defaults, "appends" params can be specified <!-- In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of to identify values which should be appended to the list of

View File

@ -716,6 +716,9 @@
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<int name="rows">10</int> <int name="rows">10</int>
<str name="df">text</str> <str name="df">text</str>
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
</lst> </lst>
<!-- In addition to defaults, "appends" params can be specified <!-- In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of to identify values which should be appended to the list of

View File

@ -713,6 +713,9 @@
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<int name="rows">10</int> <int name="rows">10</int>
<str name="df">text</str> <str name="df">text</str>
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
</lst> </lst>
<!-- In addition to defaults, "appends" params can be specified <!-- In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of to identify values which should be appended to the list of

View File

@ -46,6 +46,9 @@
<lst name="defaults"> <lst name="defaults">
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<str name="df">text</str> <str name="df">text</str>
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
</lst> </lst>
</requestHandler> </requestHandler>

View File

@ -82,8 +82,8 @@ else
echo "ERROR: HTTP POST + URL params is not accepting UTF-8 beyond the basic multilingual plane" echo "ERROR: HTTP POST + URL params is not accepting UTF-8 beyond the basic multilingual plane"
fi 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" 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 | grep "$CHAR" > /dev/null 2>&1
if [ $? = 0 ]; then if [ $? = 0 ]; then
echo "Response correctly returns UTF-8 beyond the basic multilingual plane" echo "Response correctly returns UTF-8 beyond the basic multilingual plane"
else else

View File

@ -703,7 +703,12 @@
<lst name="defaults"> <lst name="defaults">
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<int name="rows">10</int> <int name="rows">10</int>
<!-- <str name="df">text</str> --> <!-- Default search field
<str name="df">text</str>
-->
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
</lst> </lst>
<!-- In addition to defaults, "appends" params can be specified <!-- In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of to identify values which should be appended to the list of

View File

@ -716,7 +716,12 @@
<lst name="defaults"> <lst name="defaults">
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<int name="rows">10</int> <int name="rows">10</int>
<!-- <str name="df">text</str> --> <!-- Default search field
<str name="df">text</str>
-->
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
</lst> </lst>
<!-- In addition to defaults, "appends" params can be specified <!-- In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of to identify values which should be appended to the list of

View File

@ -749,6 +749,12 @@
<lst name="defaults"> <lst name="defaults">
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<int name="rows">10</int> <int name="rows">10</int>
<!-- Default search field
<str name="df">text</str>
-->
<!-- Change from JSON to XML format (the default prior to Solr 7.0)
<str name="wt">xml</str>
-->
<!-- Controls the distribution of a query to shards other than itself. <!-- Controls the distribution of a query to shards other than itself.
Consider making 'preferLocalShards' true when: Consider making 'preferLocalShards' true when:
1) maxShardsPerNode > 1 1) maxShardsPerNode > 1

View File

@ -22,13 +22,15 @@ Note that the base directory name may vary with the version of Solr downloaded.
Cygwin, or MacOS: Cygwin, or MacOS:
/:$ ls solr* /:$ ls solr*
solr-6.2.0.zip solr-X.Y.Z.zip
/:$ unzip -q solr-6.2.0.zip /:$ unzip -q solr-X.Y.Z.zip
/:$ cd solr-6.2.0/ /:$ cd solr-X.Y.Z/
Note that "X.Y.Z" will be replaced by an official Solr version (i.e. 6.4.3, 7.0.0, etc.)
To launch Solr, run: `bin/solr start -e cloud -noprompt` To launch Solr, run: `bin/solr start -e cloud -noprompt`
/solr-6.2.0:$ bin/solr start -e cloud -noprompt /solr-X.Y.Z:$ bin/solr start -e cloud -noprompt
Welcome to the SolrCloud example! Welcome to the SolrCloud example!
@ -43,7 +45,7 @@ To launch Solr, run: `bin/solr start -e cloud -noprompt`
SolrCloud example running, please visit http://localhost:8983/solr SolrCloud example running, please visit http://localhost:8983/solr
/solr-6.2.0:$ _ /solr-X.Y.Z:$ _
You can see that the Solr is running by loading the Solr Admin UI in your web browser: <http://localhost:8983/solr/>. You can see that the Solr is running by loading the Solr Admin UI in your web browser: <http://localhost:8983/solr/>.
This is the main starting point for administering Solr. This is the main starting point for administering Solr.
@ -79,8 +81,8 @@ subdirectory, so that makes a convenient set of (mostly) HTML files built-in to
Here's what it'll look like: Here's what it'll look like:
/solr-6.2.0:$ bin/post -c gettingstarted docs/ /solr-X.Y.Z:$ bin/post -c gettingstarted docs/
java -classpath /solr-6.2.0/dist/solr-core-6.2.0.jar -Dauto=yes -Dc=gettingstarted -Ddata=files -Drecursive=yes org.apache.solr.util.SimplePostTool docs/ java -classpath /solr-X.Y.Z/dist/solr-core-X.Y.Z.jar -Dauto=yes -Dc=gettingstarted -Ddata=files -Drecursive=yes org.apache.solr.util.SimplePostTool docs/
SimplePostTool version 5.0.0 SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/gettingstarted/update... Posting files to [base] url http://localhost:8983/solr/gettingstarted/update...
Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
@ -133,8 +135,8 @@ Using `bin/post`, index the example Solr XML files in `example/exampledocs/`:
Here's what you'll see: Here's what you'll see:
/solr-6.2.0:$ bin/post -c gettingstarted example/exampledocs/*.xml /solr-X.Y.Z:$ bin/post -c gettingstarted example/exampledocs/*.xml
java -classpath /solr-6.2.0/dist/solr-core-6.2.0.jar -Dauto=yes -Dc=gettingstarted -Ddata=files org.apache.solr.util.SimplePostTool example/exampledocs/gb18030-example.xml ... java -classpath /solr-X.Y.Z/dist/solr-core-X.Y.Z.jar -Dauto=yes -Dc=gettingstarted -Ddata=files org.apache.solr.util.SimplePostTool example/exampledocs/gb18030-example.xml ...
SimplePostTool version 5.0.0 SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/gettingstarted/update... Posting files to [base] url http://localhost:8983/solr/gettingstarted/update...
Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
@ -178,8 +180,8 @@ sample JSON file:
You'll see: You'll see:
/solr-6.2.0:$ bin/post -c gettingstarted example/exampledocs/books.json /solr-X.Y.Z:$ bin/post -c gettingstarted example/exampledocs/books.json
java -classpath /solr-6.2.0/dist/solr-core-6.2.0.jar -Dauto=yes -Dc=gettingstarted -Ddata=files org.apache.solr.util.SimplePostTool example/exampledocs/books.json java -classpath /solr-X.Y.Z/dist/solr-core-X.Y.Z.jar -Dauto=yes -Dc=gettingstarted -Ddata=files org.apache.solr.util.SimplePostTool example/exampledocs/books.json
SimplePostTool version 5.0.0 SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/gettingstarted/update... Posting files to [base] url http://localhost:8983/solr/gettingstarted/update...
Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
@ -207,8 +209,8 @@ Using `bin/post` index the included example CSV file:
In your terminal you'll see: In your terminal you'll see:
/solr-6.2.0:$ bin/post -c gettingstarted example/exampledocs/books.csv /solr-X.Y.Z:$ bin/post -c gettingstarted example/exampledocs/books.csv
java -classpath /solr-6.2.0/dist/solr-core-6.2.0.jar -Dauto=yes -Dc=gettingstarted -Ddata=files org.apache.solr.util.SimplePostTool example/exampledocs/books.csv java -classpath /solr-X.Y.Z/dist/solr-core-X.Y.Z.jar -Dauto=yes -Dc=gettingstarted -Ddata=files org.apache.solr.util.SimplePostTool example/exampledocs/books.csv
SimplePostTool version 5.0.0 SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/gettingstarted/update... Posting files to [base] url http://localhost:8983/solr/gettingstarted/update...
Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
@ -277,7 +279,7 @@ in the form, you'll get 10 documents in JSON format (`*:*` in the `q` param matc
The URL sent by the Admin UI to Solr is shown in light grey near the top right of the above screenshot - if you click on The URL sent by the Admin UI to Solr is shown in light grey near the top right of the above screenshot - if you click on
it, your browser will show you the raw response. To use cURL, give the same URL in quotes on the `curl` command line: it, your browser will show you the raw response. To use cURL, give the same URL in quotes on the `curl` command line:
curl "http://localhost:8983/solr/gettingstarted/select?indent=on&q=*:*&wt=json" curl "http://localhost:8983/solr/gettingstarted/select?q=*:*"
### Basics ### Basics
@ -287,11 +289,11 @@ it, your browser will show you the raw response. To use cURL, give the same URL
To search for a term, give it as the `q` param value in the core-specific Solr Admin UI Query section, replace `*:*` To search for a term, give it as the `q` param value in the core-specific Solr Admin UI Query section, replace `*:*`
with the term you want to find. To search for "foundation": with the term you want to find. To search for "foundation":
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=foundation" curl "http://localhost:8983/solr/gettingstarted/select?q=foundation"
You'll see: You'll see:
/solr-6.2.0$ curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=foundation" $ curl "http://localhost:8983/solr/gettingstarted/select?q=foundation"
{ {
"responseHeader":{ "responseHeader":{
"zkConnected":true, "zkConnected":true,
@ -315,13 +317,13 @@ default `start=0` and `rows=10`. You can specify these params to page through r
To restrict fields returned in the response, use the `fl` param, which takes a comma-separated list of field names. To restrict fields returned in the response, use the `fl` param, which takes a comma-separated list of field names.
E.g. to only return the `id` field: E.g. to only return the `id` field:
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=foundation&fl=id" curl "http://localhost:8983/solr/gettingstarted/select?q=foundation&fl=id"
`q=foundation` matches nearly all of the docs we've indexed, since most of the files under `docs/` contain `q=foundation` matches nearly all of the docs we've indexed, since most of the files under `docs/` contain
"The Apache Software Foundation". To restrict search to a particular field, use the syntax "`q=field:value`", "The Apache Software Foundation". To restrict search to a particular field, use the syntax "`q=field:value`",
e.g. to search for `Foundation` only in the `name` field: e.g. to search for `Foundation` only in the `name` field:
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=name:Foundation" curl "http://localhost:8983/solr/gettingstarted/select?q=name:Foundation"
The above request returns only one document (`"numFound":1`) - from the response: The above request returns only one document (`"numFound":1`) - from the response:
@ -339,7 +341,7 @@ To search for a multi-term phrase, enclose it in double quotes: `q="multiple ter
"CAS latency" - note that the space between terms must be converted to "`+`" in a URL (the Admin UI will handle URL "CAS latency" - note that the space between terms must be converted to "`+`" in a URL (the Admin UI will handle URL
encoding for you automatically): encoding for you automatically):
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=\"CAS+latency\"" curl "http://localhost:8983/solr/gettingstarted/select?indent=true&q=\"CAS+latency\""
You'll get back: You'll get back:
@ -374,12 +376,12 @@ To find documents that contain both terms "`one`" and "`three`", enter `+one +th
Admin UI Query tab. Because the "`+`" character has a reserved purpose in URLs (encoding the space character), Admin UI Query tab. Because the "`+`" character has a reserved purpose in URLs (encoding the space character),
you must URL encode it for `curl` as "`%2B`": you must URL encode it for `curl` as "`%2B`":
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=%2Bone+%2Bthree" curl "http://localhost:8983/solr/gettingstarted/select?q=%2Bone+%2Bthree"
To search for documents that contain the term "`two`" but **don't** contain the term "`one`", enter `+two -one` in the To search for documents that contain the term "`two`" but **don't** contain the term "`one`", enter `+two -one` in the
`q` param in the Admin UI. Again, URL encode "`+`" as "`%2B`": `q` param in the Admin UI. Again, URL encode "`+`" as "`%2B`":
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=%2Btwo+-one" curl "http://localhost:8983/solr/gettingstarted/select?q=%2Btwo+-one"
#### In depth #### In depth
@ -407,7 +409,7 @@ To see facet counts from all documents (`q=*:*`): turn on faceting (`facet=true`
the `facet.field` param. If you only want facets, and no document contents, specify `rows=0`. The `curl` command below the `facet.field` param. If you only want facets, and no document contents, specify `rows=0`. The `curl` command below
will return facet counts for the `manu_id_s` field: will return facet counts for the `manu_id_s` field:
curl 'http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=*:*&rows=0'\ curl 'http://localhost:8983/solr/gettingstarted/select?q=*:*&rows=0'\
'&facet=true&facet.field=manu_id_s' '&facet=true&facet.field=manu_id_s'
In your terminal, you'll see: In your terminal, you'll see:
@ -458,7 +460,7 @@ like this:
The data for these price range facets can be seen in JSON format with this command: The data for these price range facets can be seen in JSON format with this command:
curl 'http://localhost:8983/solr/gettingstarted/select?q=*:*&wt=json&indent=on&rows=0'\ curl 'http://localhost:8983/solr/gettingstarted/select?q=*:*&rows=0'\
'&facet=true'\ '&facet=true'\
'&facet.range=price'\ '&facet.range=price'\
'&f.price.facet.range.start=0'\ '&f.price.facet.range.start=0'\
@ -518,8 +520,7 @@ the various possible combinations. Using the example technical product data, pi
of the products in the "book" category (the `cat` field) are in stock or not in stock. Here's how to get at the raw of the products in the "book" category (the `cat` field) are in stock or not in stock. Here's how to get at the raw
data for this scenario: data for this scenario:
curl 'http://localhost:8983/solr/gettingstarted/select?q=*:*&rows=0&wt=json&indent=on'\ curl 'http://localhost:8983/solr/gettingstarted/select?q=*:*&rows=0&facet=on&facet.pivot=cat,inStock'
'&facet=on&facet.pivot=cat,inStock'
This results in the following response (trimmed to just the book category output), which says out of 14 items in the This results in the following response (trimmed to just the book category output), which says out of 14 items in the
"book" category, 12 are in stock and 2 are not in stock: "book" category, 12 are in stock and 2 are not in stock:

View File

@ -1082,7 +1082,7 @@ Returns the current status of the overseer, performance statistics of various ov
[source,text] [source,text]
---- ----
http://localhost:8983/solr/admin/collections?action=OVERSEERSTATUS&wt=json http://localhost:8983/solr/admin/collections?action=OVERSEERSTATUS
---- ----
[source,json] [source,json]
@ -1171,7 +1171,7 @@ The response will include the status of the request and the status of the cluste
[source,text] [source,text]
---- ----
http://localhost:8983/solr/admin/collections?action=clusterstatus&wt=json http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS
---- ----
*Output* *Output*
@ -1393,7 +1393,7 @@ Fetch the names of the collections in the cluster.
[source,text] [source,text]
---- ----
http://localhost:8983/solr/admin/collections?action=LIST&wt=json http://localhost:8983/solr/admin/collections?action=LIST
---- ----
*Output* *Output*

View File

@ -231,6 +231,8 @@ If set to `true`, this parameter excludes the header from the returned results.
The `wt` parameter selects the Response Writer that Solr should use to format the query's response. For detailed descriptions of Response Writers, see <<response-writers.adoc#response-writers,Response Writers>>. The `wt` parameter selects the Response Writer that Solr should use to format the query's response. For detailed descriptions of Response Writers, see <<response-writers.adoc#response-writers,Response Writers>>.
If you do not define the `wt` parameter in your queries, JSON will be returned as the format of the response.
== cache Parameter == cache Parameter
Solr caches the results of all queries and filter queries by default. To disable result caching, set the `cache=false` parameter. Solr caches the results of all queries and filter queries by default. To disable result caching, set the `cache=false` parameter.

View File

@ -214,8 +214,7 @@ Here is what a request handler looks like in `solrconfig.xml`:
<requestHandler name="/query" class="solr.SearchHandler"> <requestHandler name="/query" class="solr.SearchHandler">
<lst name="defaults"> <lst name="defaults">
<str name="echoParams">explicit</str> <str name="echoParams">explicit</str>
<str name="wt">json</str> <int name="rows">10</str>
<str name="indent">true</str>
</lst> </lst>
</requestHandler> </requestHandler>
---- ----
@ -230,8 +229,7 @@ The same request handler defined with the Config API would look like this:
"class":"solr.SearchHandler", "class":"solr.SearchHandler",
"defaults":{ "defaults":{
"echoParams":"explicit", "echoParams":"explicit",
"wt":"json", "rows": 10
"indent":true
} }
} }
} }
@ -400,7 +398,7 @@ curl http://localhost:8983/solr/techproducts/config -H 'Content-type:application
"add-requesthandler" : { "add-requesthandler" : {
"name": "/mypath", "name": "/mypath",
"class":"solr.DumpRequestHandler", "class":"solr.DumpRequestHandler",
"defaults":{ "x":"y" ,"a":"b", "wt":"json", "indent":true }, "defaults":{ "x":"y" ,"a":"b", "rows":10 },
"useParams":"x" "useParams":"x"
} }
}' }'
@ -422,7 +420,7 @@ And you should see the following as output:
"indent":"true", "indent":"true",
"a":"b", "a":"b",
"x":"y", "x":"y",
"wt":"json"}, "rows":"10"},
"context":{ "context":{
"webapp":"/solr", "webapp":"/solr",
"path":"/mypath", "path":"/mypath",
@ -437,7 +435,7 @@ curl http://localhost:8983/solr/techproducts/config -H 'Content-type:application
"update-requesthandler": { "update-requesthandler": {
"name": "/mypath", "name": "/mypath",
"class":"solr.DumpRequestHandler", "class":"solr.DumpRequestHandler",
"defaults": {"x":"new value for X", "wt":"json", "indent":true}, "defaults": {"x":"new value for X", "rows":"20"},
"useParams":"x" "useParams":"x"
} }
}' }'

View File

@ -133,7 +133,7 @@ Fetch the names of the ConfigSets in the cluster.
[source,text] [source,text]
---- ----
http://localhost:8983/solr/admin/configs?action=LIST&wt=json http://localhost:8983/solr/admin/configs?action=LIST
---- ----
*Output* *Output*

View File

@ -65,7 +65,7 @@ There is also a way of sending REST commands to the logging endpoint to do the s
[source,bash] [source,bash]
---- ----
# Set the root logger to level WARN # Set the root logger to level WARN
curl -s http://localhost:8983/solr/admin/info/logging --data-binary "set=root:WARN&wt=json" curl -s http://localhost:8983/solr/admin/info/logging --data-binary "set=root:WARN"
---- ----
== Choosing Log Level at Startup == Choosing Log Level at Startup

View File

@ -698,5 +698,5 @@ When rolling in upgrades to your indexer or application, you should shutdown the
curl http://<Source>/solr/cloud1/update -H 'Content-type:application/json' -d '[{"SKU":"ABC"}]' curl http://<Source>/solr/cloud1/update -H 'Content-type:application/json' -d '[{"SKU":"ABC"}]'
#check the Target #check the Target
curl "http://<Target>:8983/solr/<collection_name>/select?q=SKU:ABC&wt=json&indent=true" curl "http://<Target>:8983/solr/<collection_name>/select?q=SKU:ABC&indent=true"
---- ----

View File

@ -265,7 +265,7 @@ To get the resulting cluster status (again, if you have not enabled client authe
[source,bash] [source,bash]
---- ----
curl -E solr-ssl.pem:secret --cacert solr-ssl.pem "https://localhost:8984/solr/admin/collections?action=CLUSTERSTATUS&wt=json&indent=on" curl -E solr-ssl.pem:secret --cacert solr-ssl.pem "https://localhost:8984/solr/admin/collections?action=CLUSTERSTATUS&indent=on"
---- ----
You should get a response that looks like this: You should get a response that looks like this:
@ -321,7 +321,7 @@ Use cURL to query the SolrCloud collection created above, from a directory conta
[source,bash] [source,bash]
---- ----
curl -E solr-ssl.pem:secret --cacert solr-ssl.pem "https://localhost:8984/solr/mycollection/select?q=*:*&wt=json&indent=on" curl -E solr-ssl.pem:secret --cacert solr-ssl.pem "https://localhost:8984/solr/mycollection/select?q=*:*"
---- ----
=== Index a Document using CloudSolrClient === Index a Document using CloudSolrClient

View File

@ -253,12 +253,11 @@ The `facet.pivot` parameter defines the fields to use for the pivot. Multiple `f
The `facet.pivot.mincount` parameter defines the minimum number of documents that need to match in order for the facet to be included in results. The default is 1. The `facet.pivot.mincount` parameter defines the minimum number of documents that need to match in order for the facet to be included in results. The default is 1.
+ +
Using the "`bin/solr -e techproducts`" example, A query URL like this one will return the data below, with the pivot faceting results found in the section "facet_pivot": Using the "`bin/solr -e techproducts`" example, A query URL like this one will return the data below, with the pivot faceting results found in the section "facet_pivot":
+
[source,text] [source,text]
---- ----
http://localhost:8983/solr/techproducts/select?q=*:*&facet.pivot=cat,popularity,inStock http://localhost:8983/solr/techproducts/select?q=*:*&facet.pivot=cat,popularity,inStock
&facet.pivot=popularity,cat&facet=true&facet.field=cat&facet.limit=5 &facet.pivot=popularity,cat&facet=true&facet.field=cat&facet.limit=5&rows=0&facet.pivot.mincount=2
&rows=0&wt=json&indent=true&facet.pivot.mincount=2
---- ----
+ +
[source,json] [source,json]

View File

@ -100,7 +100,7 @@ Using the example documents included with Solr, we can see how this might work:
In response to a query such as: In response to a query such as:
[source,text] [source,text]
http://localhost:8983/solr/gettingstarted/select?hl=on&q=apple&wt=json&hl.fl=manu&fl=id,name,manu,cat http://localhost:8983/solr/gettingstarted/select?hl=on&q=apple&hl.fl=manu&fl=id,name,manu,cat
we get a response such as this (truncated slightly for space): we get a response such as this (truncated slightly for space):

View File

@ -32,7 +32,7 @@ Restricts results by category name.
Specifies whether statistics are returned with results. You can override the `stats` parameter on a per-field basis. The default is `false`. Specifies whether statistics are returned with results. You can override the `stats` parameter on a per-field basis. The default is `false`.
`wt`:: `wt`::
The output format. This operates the same as the <<response-writers.adoc#response-writers,`wt` parameter in a query>>. The default is `xml`. The output format. This operates the same as the <<response-writers.adoc#response-writers,`wt` parameter in a query>>. The default is `json`.
== MBeanRequestHandler Examples == MBeanRequestHandler Examples
@ -47,9 +47,9 @@ To return information about the CACHE category only:
`\http://localhost:8983/solr/techproducts/admin/mbeans?cat=CACHE` `\http://localhost:8983/solr/techproducts/admin/mbeans?cat=CACHE`
To return information and statistics about the CACHE category only, formatted in JSON: To return information and statistics about the CACHE category only, formatted in XML:
`\http://localhost:8983/solr/techproducts/admin/mbeans?stats=true&cat=CACHE&indent=true&wt=json` `\http://localhost:8983/solr/techproducts/admin/mbeans?stats=true&cat=CACHE&wt=xml`
To return information for everything, and statistics for everything except the `fieldCache`: To return information for everything, and statistics for everything except the `fieldCache`:

View File

@ -390,8 +390,8 @@ Like other request handlers, the Metrics API can also take the `wt` parameter to
Request only "counter" type metrics in the "core" group, returned in JSON: Request only "counter" type metrics in the "core" group, returned in JSON:
`\http://localhost:8983/solr/admin/metrics?wt=json&type=counter&group=core` `\http://localhost:8983/solr/admin/metrics?type=counter&group=core`
Request only "core" group metrics that start with "INDEX", returned in JSON: Request only "core" group metrics that start with "INDEX", returned in XML:
`\http://localhost:8983/solr/admin/metrics?wt=json&prefix=INDEX&group=core` `\http://localhost:8983/solr/admin/metrics?wt=xml&prefix=INDEX&group=core`

View File

@ -44,7 +44,7 @@ This command will ping the core name for a response.
[source,text] [source,text]
---- ----
http://localhost:8983/solr/<collection-name>admin/ping?wt=json&distrib=true&indent=true http://localhost:8983/solr/<collection-name>/admin/ping?distrib=true
---- ----
This command will ping all replicas of the given collection name for a response This command will ping all replicas of the given collection name for a response

View File

@ -27,7 +27,7 @@ image::images/query-screen/query-top.png[image,height=400]
In this example, a query for `genre:Fantasy` was sent to a "films" collection. Defaults were used for all other options in the form, which are explained briefly in the table below, and covered in detail in later parts of this Guide. In this example, a query for `genre:Fantasy` was sent to a "films" collection. Defaults were used for all other options in the form, which are explained briefly in the table below, and covered in detail in later parts of this Guide.
The response is shown to the right of the form. Requests to Solr are simply HTTP requests, and the query submitted is shown in light type above the results; if you click on this it will open a new browser window with just this request and response (without the rest of the Solr Admin UI). The rest of the response is shown in JSON, which is part of the request (see the `wt=json` part at the end). The response is shown to the right of the form. Requests to Solr are simply HTTP requests, and the query submitted is shown in light type above the results; if you click on this it will open a new browser window with just this request and response (without the rest of the Solr Admin UI). The rest of the response is shown in JSON, which is the default output format.
The response has at least two sections, but may have several more depending on the options chosen. The two sections it always has are the `responseHeader` and the `response`. The `responseHeader` includes the status of the search (`status`), the processing time (`QTime`), and the parameters (`params`) that were used to process the query. The response has at least two sections, but may have several more depending on the options chosen. The two sections it always has are the `responseHeader` and the `response`. The `responseHeader` includes the status of the search (`status`), the processing time (`QTime`), and the parameters (`params`) that were used to process the query.
@ -54,7 +54,7 @@ fl::
Defines the fields to return for each document. You can explicitly list the stored fields, <<function-queries.adoc#function-queries,functions>>, and <<transforming-result-documents.adoc#transforming-result-documents,doc transformers>> you want to have returned by separating them with either a comma or a space. Defines the fields to return for each document. You can explicitly list the stored fields, <<function-queries.adoc#function-queries,functions>>, and <<transforming-result-documents.adoc#transforming-result-documents,doc transformers>> you want to have returned by separating them with either a comma or a space.
wt:: wt::
Specifies the Response Writer to be used to format the query response. Defaults to XML if not specified. Specifies the Response Writer to be used to format the query response. Defaults to JSON if not specified.
indent:: indent::
Click this button to request that the Response Writer use indentation to make the responses more readable. Click this button to request that the Response Writer use indentation to make the responses more readable.

View File

@ -38,8 +38,6 @@ Real Time Get requests can be performed using the `/get` handler which exists im
<requestHandler name="/get" class="solr.RealTimeGetHandler"> <requestHandler name="/get" class="solr.RealTimeGetHandler">
<lst name="defaults"> <lst name="defaults">
<str name="omitHeader">true</str> <str name="omitHeader">true</str>
<str name="wt">json</str>
<str name="indent">true</str>
</lst> </lst>
</requestHandler> </requestHandler>
---- ----

View File

@ -78,7 +78,6 @@ curl http://localhost:8983/solr/techproducts/config/params -H 'Content-type:appl
"facet.limit":5, "facet.limit":5,
"_invariants_": { "_invariants_": {
"facet":true, "facet":true,
"wt":"json"
}, },
"_appends_":{"facet.field":["field1","field2"] "_appends_":{"facet.field":["field1","field2"]
} }
@ -104,7 +103,6 @@ It will be equivalent to a standard request handler definition such as this one:
<int name="facet.limit">5</int> <int name="facet.limit">5</int>
</lst> </lst>
<lst name="invariants"> <lst name="invariants">
<str name="wt">json</str>
<bool name="facet">true</bool> <bool name="facet">true</bool>
</lst> </lst>
<lst name="appends"> <lst name="appends">

View File

@ -39,73 +39,11 @@ The `wt` parameter selects the Response Writer to be used. The list below descri
* <<Standard XML Response Writer,xml>> * <<Standard XML Response Writer,xml>>
* <<XSLT Response Writer,xslt>> * <<XSLT Response Writer,xslt>>
== 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 `<lst>` 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 `<?xml-stylesheet type="text/xsl" href="..."?>` 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 `<xsl:output>` statement in the XSLT transform, for example: `<xsl:output media-type="text/html"/>`
=== XSLT Configuration
The example below, from the `sample_techproducts_configs` <<response-writers.adoc#response-writers,config set>> in the Solr distribution, shows how the XSLT Response Writer is configured.
[source,xml]
----
<!--
Changes to XSLT transforms are taken into account
every xsltCacheLifetimeSeconds at most.
-->
<queryResponseWriter name="xslt"
class="org.apache.solr.request.XSLTResponseWriter">
<int name="xsltCacheLifetimeSeconds">5</int>
</queryResponseWriter>
----
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 == 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] [source,json]
---- ----
@ -115,9 +53,7 @@ Here is a sample response for a simple query like `q=id:VS1GB400C3&wt=json`:
"status":0, "status":0,
"QTime":7, "QTime":7,
"params":{ "params":{
"q":"id:VS1GB400C3", "q":"id:VS1GB400C3"}},
"indent":"on",
"wt":"json"}},
"response":{"numFound":1,"start":0,"maxScore":2.3025851,"docs":[ "response":{"numFound":1,"start":0,"maxScore":2.3025851,"docs":[
{ {
"id":"VS1GB400C3", "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.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/ * 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 `<lst>` 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 `<?xml-stylesheet type="text/xsl" href="..."?>` 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 `<xsl:output>` statement in the XSLT transform, for example: `<xsl:output media-type="text/html"/>`
=== XSLT Configuration
The example below, from the `sample_techproducts_configs` <<response-writers.adoc#response-writers,config set>> in the Solr distribution, shows how the XSLT Response Writer is configured.
[source,xml]
----
<!--
Changes to XSLT transforms are taken into account
every xsltCacheLifetimeSeconds at most.
-->
<queryResponseWriter name="xslt"
class="org.apache.solr.request.XSLTResponseWriter">
<int name="xsltCacheLifetimeSeconds">5</int>
</queryResponseWriter>
----
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 == 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 <<client-apis.adoc#client-apis,Client APIs>> for more details. 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 <<client-apis.adoc#client-apis,Client APIs>> for more details.

View File

@ -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. 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] [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. 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] [source,json]
---- ----
@ -191,8 +191,7 @@ We can run the same query with the request parameter `group.main=true`. This wil
"q":"solr memory", "q":"solr memory",
"group.field":"manu_exact", "group.field":"manu_exact",
"group.main":"true", "group.main":"true",
"group":"true", "group":"true"}},
"wt":"json"}},
"grouped":{}, "grouped":{},
"response":{"numFound":6,"start":0,"docs":[ "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. 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] [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.limit":"3",
"group.query":["price:[0 TO 99.99]", "group.query":["price:[0 TO 99.99]",
"price:[100 TO *]"], "price:[100 TO *]"],
"group":"true", "group":"true"}},
"wt":"json"}},
"grouped":{ "grouped":{
"price:[0 TO 99.99]":{ "price:[0 TO 99.99]":{
"matches":5, "matches":5,

View File

@ -420,7 +420,7 @@ Get the entire schema in JSON.
[source,bash] [source,bash]
---- ----
curl http://localhost:8983/solr/gettingstarted/schema?wt=json curl http://localhost:8983/solr/gettingstarted/schema
---- ----
[source,json] [source,json]
@ -609,7 +609,7 @@ Get a list of all fields.
[source,bash] [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. 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] [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. The sample output below has been truncated.
@ -765,7 +765,7 @@ Get a list of all field types.
[source,bash] [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. 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] [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. The sample output below has been truncated to the first few copy definitions.
@ -914,7 +914,7 @@ Get the schema name.
[source,bash] [source,bash]
---- ----
curl http://localhost:8983/solr/gettingstarted/schema/name?wt=json curl http://localhost:8983/solr/gettingstarted/schema/name
---- ----
[source,json] [source,json]
@ -954,7 +954,7 @@ Get the schema version
[source,bash] [source,bash]
---- ----
curl http://localhost:8983/solr/gettingstarted/schema/version?wt=json curl http://localhost:8983/solr/gettingstarted/schema/version
---- ----
[source,json] [source,json]
@ -995,7 +995,7 @@ List the uniqueKey.
[source,bash] [source,bash]
---- ----
curl http://localhost:8983/solr/gettingstarted/schema/uniquekey?wt=json curl http://localhost:8983/solr/gettingstarted/schema/uniquekey
---- ----
[source,json] [source,json]
@ -1035,7 +1035,7 @@ Get the similarity implementation.
[source,bash] [source,bash]
---- ----
curl http://localhost:8983/solr/gettingstarted/schema/similarity?wt=json curl http://localhost:8983/solr/gettingstarted/schema/similarity
---- ----
[source,json] [source,json]

View File

@ -414,7 +414,7 @@ Example query:
[source,text] [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). 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] [source,text]
---- ----
http://localhost:8983/solr/techproducts/suggest?suggest=true& \ http://localhost:8983/solr/techproducts/suggest?suggest=true&suggest.dictionary=mySuggester&suggest.dictionary=altSuggester&suggest.q=elec
suggest.dictionary=mySuggester&suggest.dictionary=altSuggester&wt=json&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. 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] [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'. The suggester will only bring back suggestions for products tagged with 'cat=memory'.

View File

@ -260,7 +260,7 @@ Result:
</response> </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: Result:

View File

@ -97,10 +97,10 @@ Augments each document with an inline explanation of its score exactly like the
[source,plain] [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] [source,json]
---- ----

View File

@ -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. 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: For more information and an excellent example, read the SolJSON page on the Solr Wiki:

View File

@ -58,7 +58,7 @@ JSON is a more robust response format, but you will need to add a Python package
sudo easy_install simplejson 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] [source,python]
---- ----

View File

@ -255,6 +255,8 @@ public class SolrStream extends TupleStream {
if (p != null) { if (p != null) {
ModifiableSolrParams modifiableSolrParams = (ModifiableSolrParams) requestParams; ModifiableSolrParams modifiableSolrParams = (ModifiableSolrParams) requestParams;
modifiableSolrParams.remove("qt"); 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"); String wt = requestParams.get(CommonParams.WT, "json");

View File

@ -850,6 +850,13 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
public static void assertQ(String message, SolrQueryRequest req, String... tests) { public static void assertQ(String message, SolrQueryRequest req, String... tests) {
try { try {
String m = (null == message) ? "" : message + " "; // TODO log 'm' !!! 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); String response = h.query(req);
if (req.getParams().getBool("facet", false)) { if (req.getParams().getBool("facet", false)) {

View File

@ -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. * 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 paramToSet The parameter name to insure the presence of in the returned request
* @param valueToSet The parameter value to insure 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 * @return The query with the given param set to the given value

View File

@ -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, * 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 * @param request the URL path and optional query params
* @return The response to the query * @return The response to the query
@ -181,10 +181,10 @@ public class RestTestHarness extends BaseTestHarness implements Closeable {
@Override @Override
public void reload() throws Exception { public void reload() throws Exception {
String coreName = (String)evaluateXPath String coreName = (String)evaluateXPath
(adminQuery("/admin/cores?action=STATUS"), (adminQuery("/admin/cores?wt=xml&action=STATUS"),
"//lst[@name='status']/lst[1]/str[@name='name']", "//lst[@name='status']/lst[1]/str[@name='name']",
XPathConstants.STRING); 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) { if (null != xml) {
throw new RuntimeException("RELOAD failed:\n" + xml); throw new RuntimeException("RELOAD failed:\n" + xml);
} }

View File

@ -20,7 +20,7 @@ solrAdminApp.controller('QueryController',
$scope.resetMenu("query", Constants.IS_COLLECTION_PAGE); $scope.resetMenu("query", Constants.IS_COLLECTION_PAGE);
// @todo read URL parameters into scope // @todo read URL parameters into scope
$scope.query = {wt: 'json', q:'*:*', indent:'on'}; $scope.query = {q:'*:*'};
$scope.filters = [{fq:""}]; $scope.filters = [{fq:""}];
$scope.dismax = {defType: "dismax"}; $scope.dismax = {defType: "dismax"};
$scope.edismax = {defType: "edismax", stopwords: true, lowercaseOperators: false}; $scope.edismax = {defType: "edismax", stopwords: true, lowercaseOperators: false};
@ -87,6 +87,9 @@ solrAdminApp.controller('QueryController',
var url = Query.url(params); var url = Query.url(params);
Query.query(params, function(data) { Query.query(params, function(data) {
$scope.lang = $scope.query.wt; $scope.lang = $scope.query.wt;
if ($scope.lang == undefined || $scope.lang == '') {
$scope.lang = "json";
}
$scope.response = data; $scope.response = data;
// Use relative URL to make it also work through proxies that may have a different host/port/context // Use relative URL to make it also work through proxies that may have a different host/port/context
$scope.url = url; $scope.url = url;

View File

@ -78,6 +78,7 @@ limitations under the License.
<a rel="help">wt</a> <a rel="help">wt</a>
</label> </label>
<select name="wt" ng-model="query.wt" id="wt" title="The writer type (response format)."> <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>json</option>
<option>xml</option> <option>xml</option>
<option>python</option> <option>python</option>
@ -86,9 +87,9 @@ limitations under the License.
<option>csv</option> <option>csv</option>
</select> </select>
<label for="indent" class="checkbox" title="Indent results."> <label for="indent off" class="checkbox" title="Do not indent results.">
<input type="checkbox" ng-model="query.indent" name="indent" id="indent" title="Indent results." ng-true-value="'on'" ng-false-value="''"> <input type="checkbox" ng-model="query.indent" name="indent" id="indent" title="Do not indent results." ng-true-value="'off'" ng-false-value="''">
indent indent off
</label> </label>
<label for="debugQuery" class="checkbox" title="Show timing and diagnostics."> <label for="debugQuery" class="checkbox" title="Show timing and diagnostics.">