use of org.apache.solr.update.AddUpdateCommand in project lucene-solr by apache.
the class SkipExistingDocumentsProcessorFactoryTest method testSkippableUpdateIsSkippedIfSkipUpdatesTrue.
@Test
public void testSkippableUpdateIsSkippedIfSkipUpdatesTrue() throws IOException {
UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
SkipExistingDocumentsUpdateProcessor processor = Mockito.spy(new SkipExistingDocumentsUpdateProcessor(defaultRequest, next, false, true));
AddUpdateCommand cmd = createAtomicUpdateCmd(defaultRequest);
doReturn(true).when(processor).isLeader(cmd);
doReturn(false).when(processor).doesDocumentExist(docId);
processor.processAdd(cmd);
verify(next, never()).processAdd(cmd);
}
use of org.apache.solr.update.AddUpdateCommand in project lucene-solr by apache.
the class RegexBoostProcessorTest method processAdd.
private void processAdd(SolrInputDocument doc) throws Exception {
AddUpdateCommand addCommand = new AddUpdateCommand(null);
addCommand.solrDoc = doc;
reProcessor.processAdd(addCommand);
}
use of org.apache.solr.update.AddUpdateCommand in project lucene-solr by apache.
the class XmlUpdateRequestHandlerTest method testExternalEntities.
@Test
public void testExternalEntities() throws Exception {
String file = getFile("mailing_lists.pdf").toURI().toASCIIString();
String xml = "<?xml version=\"1.0\"?>" + // check that external entities are not resolved!
"<!DOCTYPE foo [<!ENTITY bar SYSTEM \"" + file + "\">]>" + "<add>" + " &bar;" + " <doc>" + " <field name=\"id\">12345</field>" + " <field name=\"name\">kitten</field>" + " </doc>" + "</add>";
SolrQueryRequest req = req();
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
XMLLoader loader = new XMLLoader().init(null);
loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals("12345", add.solrDoc.getField("id").getFirstValue());
req.close();
}
use of org.apache.solr.update.AddUpdateCommand in project lucene-solr by apache.
the class XmlUpdateRequestHandlerTest method testRequestParams.
@Test
public void testRequestParams() throws Exception {
String xml = "<add>" + " <doc>" + " <field name=\"id\">12345</field>" + " <field name=\"name\">kitten</field>" + " </doc>" + "</add>";
SolrQueryRequest req = req("commitWithin", "100", "overwrite", "false");
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
XMLLoader loader = new XMLLoader().init(null);
loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(100, add.commitWithin);
assertEquals(false, add.overwrite);
req.close();
}
use of org.apache.solr.update.AddUpdateCommand in project lucene-solr by apache.
the class ClassificationUpdateProcessorTest method knnClassification_maxOutputClassesGreaterThanAvailable_shouldAssignCorrectClass.
@Test
public void knnClassification_maxOutputClassesGreaterThanAvailable_shouldAssignCorrectClass() throws Exception {
UpdateRequestProcessor mockProcessor = mock(UpdateRequestProcessor.class);
prepareTrainedIndexMultiClass();
AddUpdateCommand update = new AddUpdateCommand(req());
SolrInputDocument unseenDocument1 = sdoc(ID, "10", TITLE, "word1 word1 word1", CONTENT, "word2 word2 ", AUTHOR, "unseenAuthor");
update.solrDoc = unseenDocument1;
ClassificationUpdateProcessorParams params = initParams(ClassificationUpdateProcessorFactory.Algorithm.KNN);
params.setMaxPredictedClasses(100);
updateProcessorToTest = new ClassificationUpdateProcessor(params, mockProcessor, reader, req().getSchema());
updateProcessorToTest.processAdd(update);
ArrayList<Object> assignedClasses = (ArrayList) unseenDocument1.getFieldValues(TRAINING_CLASS);
assertThat(assignedClasses.get(0), is("class2"));
assertThat(assignedClasses.get(1), is("class1"));
}
Aggregations