use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class TestReplicaProperties method addProperty.
private void addProperty(CloudSolrClient client, String... paramsIn) throws IOException, SolrServerException {
assertTrue("paramsIn must be an even multiple of 2, it is: " + paramsIn.length, (paramsIn.length % 2) == 0);
ModifiableSolrParams params = new ModifiableSolrParams();
for (int idx = 0; idx < paramsIn.length; idx += 2) {
params.set(paramsIn[idx], paramsIn[idx + 1]);
}
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
client.request(request);
}
use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class TestSmileRequest method testDistribJsonRequest.
@Test
public void testDistribJsonRequest() throws Exception {
initServers();
SolrTestCaseHS.Client client = servers.getClient(random().nextInt());
client.tester = new SolrTestCaseHS.Client.Tester() {
@Override
public void assertJQ(SolrClient client, SolrParams args, String... tests) throws Exception {
((HttpSolrClient) client).setParser(SmileResponseParser.inst);
QueryRequest query = new QueryRequest(args);
String path = args.get("qt");
if (path != null) {
query.setPath(path);
}
NamedList<Object> rsp = client.request(query);
Map m = rsp.asMap(5);
String jsonStr = Utils.toJSONString(m);
SolrTestCaseHS.matchJSON(jsonStr, tests);
}
};
client.queryDefaults().set("shards", servers.getShards());
TestJsonRequest.doJsonRequest(client);
}
use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class TimeSeriesStream method open.
public void open() throws IOException {
if (cache != null) {
cloudSolrClient = cache.getCloudSolrClient(zkHost);
} else {
cloudSolrClient = new Builder().withZkHost(zkHost).build();
}
String json = getJsonFacetString(field, metrics, start, end, gap);
ModifiableSolrParams paramsLoc = new ModifiableSolrParams(params);
paramsLoc.set("json.facet", json);
paramsLoc.set("rows", "0");
QueryRequest request = new QueryRequest(paramsLoc);
try {
NamedList response = cloudSolrClient.request(request, collection);
getTuples(response, field, metrics);
} catch (Exception e) {
throw new IOException(e);
}
}
use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class TestRemoteStreaming method testQtUpdateFails.
/** SOLR-3161
* Technically stream.body isn't remote streaming, but there wasn't a better place for this test method. */
@Test(expected = SolrException.class)
public void testQtUpdateFails() throws SolrServerException, IOException {
SolrQuery query = new SolrQuery();
//for anything
query.setQuery("*:*");
query.add("echoHandler", "true");
//sneaky sneaky
query.add("qt", "/update");
query.add("stream.body", "<delete><query>*:*</query></delete>");
QueryRequest queryRequest = new QueryRequest(query) {
@Override
public String getPath() {
//don't let superclass substitute qt for the path
return "/select";
}
};
QueryResponse rsp = queryRequest.process(getSolrClient());
//!! should *fail* above for security purposes
String handler = (String) rsp.getHeader().get("handler");
System.out.println(handler);
}
use of org.apache.solr.client.solrj.request.QueryRequest in project metron by apache.
the class MetronSolrClient method getListCollectionsRequest.
public QueryRequest getListCollectionsRequest() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(SolrConstants.REQUEST_ACTION, CollectionParams.CollectionAction.LIST.name());
QueryRequest request = new QueryRequest(params);
request.setPath(SolrConstants.REQUEST_COLLECTIONS_PATH);
return request;
}
Aggregations