use of org.apache.solr.common.params.MapSolrParams in project lucene-solr by apache.
the class TestApiFramework method invoke.
private SolrQueryResponse invoke(PluginBag<SolrRequestHandler> reqHandlers, String path, String fullPath, SolrRequest.METHOD method, CoreContainer mockCC) {
HashMap<String, String> parts = new HashMap<>();
boolean containerHandlerLookup = mockCC.getRequestHandlers() == reqHandlers;
path = path == null ? fullPath : path;
Api api = null;
if (containerHandlerLookup) {
api = V2HttpCall.getApiInfo(reqHandlers, path, "GET", fullPath, parts);
} else {
api = V2HttpCall.getApiInfo(mockCC.getRequestHandlers(), fullPath, "GET", fullPath, parts);
if (api == null)
api = new CompositeApi(null);
if (api instanceof CompositeApi) {
CompositeApi compositeApi = (CompositeApi) api;
api = V2HttpCall.getApiInfo(reqHandlers, path, "GET", fullPath, parts);
compositeApi.add(api);
api = compositeApi;
}
}
SolrQueryResponse rsp = new SolrQueryResponse();
LocalSolrQueryRequest req = new LocalSolrQueryRequest(null, new MapSolrParams(new HashMap<>())) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
return Collections.emptyList();
}
};
api.call(req, rsp);
return rsp;
}
use of org.apache.solr.common.params.MapSolrParams in project lucene-solr by apache.
the class UpdateParamsTest method testUpdateProcessorParamDeprecationRemoved.
/**
* Tests that only update.chain and not update.processor works (SOLR-2105)
*/
public void testUpdateProcessorParamDeprecationRemoved() throws Exception {
SolrCore core = h.getCore();
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
MapSolrParams params = new MapSolrParams(new HashMap<String, String>());
params.getMap().put("update.processor", "nonexistant");
// Add a single document
SolrQueryResponse rsp = new SolrQueryResponse();
SolrQueryRequestBase req = new SolrQueryRequestBase(core, params) {
};
// First check that the old param behaves as it should
try {
handler.handleRequestBody(req, rsp);
assertTrue("Old param update.processor should not have any effect anymore", true);
} catch (Exception e) {
assertFalse("Got wrong exception while testing update.chain", e.getMessage().equals("unknown UpdateRequestProcessorChain: nonexistant"));
}
// Then check that the new param behaves correctly
params.getMap().remove("update.processor");
params.getMap().put(UpdateParams.UPDATE_CHAIN, "nonexistant");
req.setParams(params);
try {
handler.handleRequestBody(req, rsp);
assertFalse("Faulty update.chain parameter not causing an error - i.e. it is not detected", true);
} catch (Exception e) {
assertEquals("Got wrong exception while testing update.chain", e.getMessage(), "unknown UpdateRequestProcessorChain: nonexistant");
}
}
use of org.apache.solr.common.params.MapSolrParams in project lucene-solr by apache.
the class StatsComponentTest method testFieldStatisticsResultsStringFieldAlwaysMissing.
public void testFieldStatisticsResultsStringFieldAlwaysMissing() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1"));
assertU(adoc("id", "2"));
assertU(commit());
assertU(adoc("id", "3"));
assertU(adoc("id", "4"));
assertU(commit());
Map<String, String> args = new HashMap<>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_s");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req, "//lst[@name='active_s']/long[@name='count'][.='0']", "//lst[@name='active_s']/long[@name='missing'][.='4']", "//lst[@name='active_s']/null[@name='min']", "//lst[@name='active_s']/null[@name='max']", // if new stats are supported, this will break - update test to assert values for each
"count(//lst[@name='active_s']/*)=4");
assertQ("test string statistics values", req("q", "*:*", "stats", "true", "stats.field", "{!cardinality=true}active_s"), "//lst[@name='active_s']/long[@name='cardinality'][.='0']");
}
use of org.apache.solr.common.params.MapSolrParams in project lucene-solr by apache.
the class StatsComponentTest method testFieldStatisticsDocValuesAndMultiValued.
// SOLR-6024
public void testFieldStatisticsDocValuesAndMultiValued() throws Exception {
SolrCore core = h.getCore();
// precondition for the test
SchemaField catDocValues = core.getLatestSchema().getField("cat_docValues");
assertTrue("schema no longer satisfies test requirements: cat_docValues no longer multivalued", catDocValues.multiValued());
assertTrue("schema no longer satisfies test requirements: cat_docValues fieldtype no longer single valued", !catDocValues.getType().isMultiValued());
assertTrue("schema no longer satisfies test requirements: cat_docValues no longer has docValues", catDocValues.hasDocValues());
List<FldType> types = new ArrayList<>();
types.add(new FldType("id", ONE_ONE, new SVal('A', 'Z', 4, 4)));
types.add(new FldType("cat_docValues", new IRange(2, 2), new SVal('a', 'z', 1, 30)));
Doc d1 = createDoc(types);
d1.getValues("id").set(0, "1");
d1.getValues("cat_docValues").set(0, "test");
d1.getValues("cat_docValues").set(1, "testtw");
updateJ(toJSON(d1), null);
Doc d2 = createDoc(types);
d2.getValues("id").set(0, "2");
d2.getValues("cat_docValues").set(0, "test");
d2.getValues("cat_docValues").set(1, "testtt");
updateJ(toJSON(d2), null);
assertU(commit());
Map<String, String> args = new HashMap<>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "cat_docValues");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test min/max on docValues and multiValued", req, "//lst[@name='cat_docValues']/str[@name='min'][.='test']", "//lst[@name='cat_docValues']/str[@name='max'][.='testtw']");
assertQ("cardinality", req("q", "*:*", "stats", "true", "stats.field", "{!cardinality=true}cat_docValues"), "//lst[@name='cat_docValues']/long[@name='cardinality'][.='3']");
}
use of org.apache.solr.common.params.MapSolrParams in project lucene-solr by apache.
the class StatsComponentTest method testFieldStatisticsResultsNumericFieldAlwaysMissing.
public void testFieldStatisticsResultsNumericFieldAlwaysMissing() throws Exception {
SolrCore core = h.getCore();
assertU(adoc("id", "1"));
assertU(adoc("id", "2"));
assertU(commit());
assertU(adoc("id", "3"));
assertU(adoc("id", "4"));
assertU(commit());
Map<String, String> args = new HashMap<>();
args.put(CommonParams.Q, "*:*");
args.put(StatsParams.STATS, "true");
args.put(StatsParams.STATS_FIELD, "active_i");
args.put("indent", "true");
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
assertQ("test string statistics values", req, "//lst[@name='active_i']/long[@name='count'][.='0']", "//lst[@name='active_i']/long[@name='missing'][.='4']", "//lst[@name='active_i']/null[@name='min']", "//lst[@name='active_i']/null[@name='max']", "//lst[@name='active_i']/double[@name='sum'][.='0.0']", "//lst[@name='active_i']/double[@name='sumOfSquares'][.='0.0']", "//lst[@name='active_i']/double[@name='stddev'][.='0.0']", "//lst[@name='active_i']/double[@name='mean'][.='NaN']", // if new stats are supported, this will break - update test to assert values for each
"count(//lst[@name='active_i']/*)=8");
// NOTE: empty set percentiles covered in testPercentiles()
assertQ("test cardinality of missing", req("q", "*:*", "stats", "true", "stats.field", "{!cardinality=true}active_i"), "//lst[@name='active_i']/long[@name='cardinality'][.='0']");
}
Aggregations