use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class SpellCheckCollatorTest method testCollationWithHypens.
@Test
public void testCollationWithHypens() 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(CommonParams.Q, "lowerfilt:(hypenated-wotd)");
{
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();
assertTrue("Incorrect collation: " + collation, "lowerfilt:(hyphenated-word)".equals(collation));
}
params.remove(CommonParams.Q);
params.add("defType", "dismax");
params.add("qf", "lowerfilt");
params.add(CommonParams.Q, "hypenated-wotd");
{
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.add("responseHeader", 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();
assertTrue("Incorrect collation: " + collation, "hyphenated-word".equals(collation));
}
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class IgnoreCommitOptimizeUpdateProcessorFactoryTest method processCommit.
SolrQueryResponse processCommit(final String chain, boolean optimize, Boolean commitEndPoint) throws IOException {
SolrCore core = h.getCore();
UpdateRequestProcessorChain pc = core.getUpdateProcessingChain(chain);
assertNotNull("No Chain named: " + chain, pc);
SolrQueryResponse rsp = new SolrQueryResponse();
SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());
if (commitEndPoint != null) {
((ModifiableSolrParams) req.getParams()).set(DistributedUpdateProcessor.COMMIT_END_POINT, commitEndPoint.booleanValue());
}
try {
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
CommitUpdateCommand cmd = new CommitUpdateCommand(req, false);
cmd.optimize = optimize;
UpdateRequestProcessor processor = pc.createProcessor(req, rsp);
processor.processCommit(cmd);
} finally {
SolrRequestInfo.clearRequestInfo();
req.close();
}
return rsp;
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class IgnoreCommitOptimizeUpdateProcessorFactoryTest method testIgnoreCommit.
public void testIgnoreCommit() throws Exception {
// verify that the processor returns an error if it receives a commit
SolrQueryResponse rsp = processCommit("ignore-commit-from-client-403", false);
assertNotNull("Sending a commit should have resulted in an exception in the response", rsp.getException());
rsp = processCommit("ignore-commit-from-client-200", false);
Exception shouldBeNull = rsp.getException();
assertNull("Sending a commit should NOT have resulted in an exception in the response: " + shouldBeNull, shouldBeNull);
rsp = processCommit("ignore-optimize-only-from-client-403", true);
assertNotNull("Sending an optimize should have resulted in an exception in the response", rsp.getException());
// commit should happen if DistributedUpdateProcessor.COMMIT_END_POINT == true
rsp = processCommit("ignore-commit-from-client-403", false, new Boolean(true));
shouldBeNull = rsp.getException();
assertNull("Sending a commit should NOT have resulted in an exception in the response: " + shouldBeNull, shouldBeNull);
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class SkipExistingDocumentsProcessorFactoryTest method testSkipInsertsFalseIfInInitArgs.
@Test
public void testSkipInsertsFalseIfInInitArgs() {
SkipExistingDocumentsProcessorFactory factory = new SkipExistingDocumentsProcessorFactory();
NamedList<Object> initArgs = new NamedList<>();
initArgs.add("skipInsertIfExists", false);
factory.init(initArgs);
UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
SkipExistingDocumentsUpdateProcessor processor = factory.getInstance(defaultRequest, new SolrQueryResponse(), next);
assertFalse("Expected skipInsertIfExists to be false", processor.isSkipInsertIfExists());
assertTrue("Expected skipUpdateIfMissing to be true", processor.isSkipUpdateIfMissing());
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class SkipExistingDocumentsProcessorFactoryTest method testSkipInsertsAndUpdatesDefaultToTrueIfNotConfigured.
@Test
public void testSkipInsertsAndUpdatesDefaultToTrueIfNotConfigured() {
SkipExistingDocumentsProcessorFactory factory = new SkipExistingDocumentsProcessorFactory();
NamedList<Object> initArgs = new NamedList<>();
factory.init(initArgs);
UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
SkipExistingDocumentsUpdateProcessor processor = factory.getInstance(defaultRequest, new SolrQueryResponse(), next);
assertTrue("Expected skipInsertIfExists to be true", processor.isSkipInsertIfExists());
assertTrue("Expected skipUpdateIfMissing to be true", processor.isSkipUpdateIfMissing());
}
Aggregations