use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class RequestHandlerBase method getRequestHandler.
/**
* Get the request handler registered to a given name.
*
* This function is thread safe.
*/
public static SolrRequestHandler getRequestHandler(String handlerName, PluginBag<SolrRequestHandler> reqHandlers) {
if (handlerName == null)
return null;
SolrRequestHandler handler = reqHandlers.get(handlerName);
int idx = 0;
if (handler == null) {
for (; ; ) {
idx = handlerName.indexOf('/', idx + 1);
if (idx > 0) {
String firstPart = handlerName.substring(0, idx);
handler = reqHandlers.get(firstPart);
if (handler == null)
continue;
if (handler instanceof NestedRequestHandler) {
return ((NestedRequestHandler) handler).getSubHandler(handlerName.substring(idx));
}
} else {
break;
}
}
}
return handler;
}
use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class TestCrossCoreJoin method update.
public static String update(SolrCore core, String xml) throws Exception {
DirectSolrConnection connection = new DirectSolrConnection(core);
SolrRequestHandler handler = core.getRequestHandler("/update");
return connection.request(handler, null, xml);
}
use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class TestInitParams method testComponentWithInitParams.
@Test
public void testComponentWithInitParams() {
for (String s : Arrays.asList("/dump1", "/dump3", "/root/dump5", "/root1/anotherlevel/dump6")) {
SolrRequestHandler handler = h.getCore().getRequestHandler(s);
SolrQueryResponse rsp = new SolrQueryResponse();
handler.handleRequest(req("initArgs", "true"), rsp);
NamedList nl = (NamedList) rsp.getValues().get("initArgs");
NamedList def = (NamedList) nl.get(PluginInfo.DEFAULTS);
assertEquals("A", def.get("a"));
def = (NamedList) nl.get(PluginInfo.INVARIANTS);
assertEquals("B", def.get("b"));
def = (NamedList) nl.get(PluginInfo.APPENDS);
assertEquals("C", def.get("c"));
}
InitParams initParams = h.getCore().getSolrConfig().getInitParams().get("a");
PluginInfo pluginInfo = new PluginInfo("requestHandler", new HashMap<String, String>(), new NamedList<>(singletonMap("defaults", new NamedList(Utils.makeMap("a", "A1")))), null);
initParams.apply(pluginInfo);
assertEquals("A", initParams.defaults.get("a"));
}
use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class SpellCheckCollatorTest method testCollationWithRangeQuery.
@Test
public void testCollationWithRangeQuery() throws Exception {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
assertTrue("speller is null and it shouldn't be", speller != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
params.add(SpellingParams.SPELLCHECK_BUILD, "true");
params.add(SpellingParams.SPELLCHECK_COUNT, "10");
params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
params.add(SpellingParams.SPELLCHECK_ALTERNATIVE_TERM_COUNT, "10");
params.add(CommonParams.Q, "id:[1 TO 10] AND lowerfilt:lovw");
{
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.addResponseHeader(new SimpleOrderedMap());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
handler.handleRequest(req, rsp);
req.close();
NamedList values = rsp.getValues();
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList collationHolder = (NamedList) spellCheck.get("collations");
List<String> collations = collationHolder.getAll("collation");
assertTrue(collations.size() == 1);
String collation = collations.iterator().next();
System.out.println(collation);
assertTrue("Incorrect collation: " + collation, "id:[1 TO 10] AND lowerfilt:love".equals(collation));
}
}
use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class SpellCheckCollatorTest method testWithCursorMark.
@Test
public void testWithCursorMark() throws Exception {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
assertTrue("speller is null and it shouldn't be", speller != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10");
params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");
params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "2");
params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1");
params.add(CommonParams.Q, "lowerfilt:(+fauth)");
params.add(CommonParams.SORT, "id asc");
params.add(CursorMarkParams.CURSOR_MARK_PARAM, CursorMarkParams.CURSOR_MARK_START);
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.addResponseHeader(new SimpleOrderedMap());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
handler.handleRequest(req, rsp);
req.close();
NamedList values = rsp.getValues();
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList collationList = (NamedList) spellCheck.get("collations");
List<?> collations = (List<?>) collationList.getAll("collation");
assertTrue(collations.size() == 1);
}
Aggregations