use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class SpellCheckCollatorTest method testCollateWithFilter.
@Test
public void testCollateWithFilter() 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_MAX_COLLATION_TRIES, "10");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10");
params.add(CommonParams.Q, "lowerfilt:(+fauth +home +loane)");
params.add(CommonParams.FQ, "NOT(id:1)");
//Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
//not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
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() > 0);
for (String collation : collations) {
assertTrue(!collation.equals("lowerfilt:(+faith +hope +loaves)"));
}
}
use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class SpellCheckCollatorTest method testCollateWithGrouping.
@Test
public void testCollateWithGrouping() 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_MAX_COLLATION_TRIES, "5");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1");
params.add(CommonParams.Q, "lowerfilt:(+fauth)");
params.add(GroupParams.GROUP, "true");
params.add(GroupParams.GROUP_FIELD, "id");
//Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
//not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
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);
}
use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class SpellCheckCollatorTest method testZeroTries.
@Test
public void testZeroTries() 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, "0");
params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "2");
params.add(CommonParams.Q, "lowerfilt:(+fauth)");
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() == 2);
}
use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class TestHarness method update.
/**
* Processes an "update" (add, commit or optimize) and
* returns the response as a String.
*
* @param xml The XML of the update
* @return The XML response to the update
*/
public String update(String xml) {
try (SolrCore core = getCoreInc()) {
DirectSolrConnection connection = new DirectSolrConnection(core);
SolrRequestHandler handler = core.getRequestHandler("/update");
// if that lookup fails
if (handler == null) {
handler = updater;
}
return connection.request(handler, null, xml);
} catch (SolrException e) {
throw (SolrException) e;
} catch (Exception e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
}
}
use of org.apache.solr.request.SolrRequestHandler in project lucene-solr by apache.
the class RequestHandlersTest method testPathNormalization.
@Test
public void testPathNormalization() {
SolrCore core = h.getCore();
SolrRequestHandler h1 = core.getRequestHandler("/update");
assertNotNull(h1);
SolrRequestHandler h2 = core.getRequestHandler("/update/");
assertNotNull(h2);
// the same object
assertEquals(h1, h2);
// prefix
assertNull(core.getRequestHandler("/update/asdgadsgas"));
}
Aggregations