use of org.apache.solr.update.DeleteUpdateCommand in project lucene-solr by apache.
the class SolrWriter method doDeleteAll.
@Override
public void doDeleteAll() {
try {
DeleteUpdateCommand deleteCommand = new DeleteUpdateCommand(req);
deleteCommand.query = "*:*";
processor.processDelete(deleteCommand);
} catch (IOException e) {
throw new DataImportHandlerException(DataImportHandlerException.SEVERE, "Exception in full dump while deleting all documents.", e);
}
}
use of org.apache.solr.update.DeleteUpdateCommand in project lucene-solr by apache.
the class SolrWriter method deleteDoc.
@Override
public void deleteDoc(Object id) {
try {
log.info("Deleting document: " + id);
DeleteUpdateCommand delCmd = new DeleteUpdateCommand(req);
delCmd.setId(id.toString());
processor.processDelete(delCmd);
} catch (IOException e) {
log.error("Exception while deleteing: " + id, e);
}
}
use of org.apache.solr.update.DeleteUpdateCommand in project lucene-solr by apache.
the class JsonLoaderTest method testParsing.
public void testParsing() throws Exception {
SolrQueryRequest req = req();
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
JsonLoader loader = new JsonLoader();
loader.load(req, rsp, new ContentStreamBase.StringStream(input), p);
assertEquals(2, p.addCommands.size());
AddUpdateCommand add = p.addCommands.get(0);
SolrInputDocument d = add.solrDoc;
SolrInputField f = d.getField("boosted");
assertEquals(2, f.getValues().size());
//
add = p.addCommands.get(1);
d = add.solrDoc;
f = d.getField("f1");
assertEquals(2, f.getValues().size());
assertEquals(false, add.overwrite);
assertEquals(0, d.getField("f2").getValueCount());
// parse the commit commands
assertEquals(2, p.commitCommands.size());
CommitUpdateCommand commit = p.commitCommands.get(0);
assertFalse(commit.optimize);
assertTrue(commit.waitSearcher);
assertTrue(commit.openSearcher);
commit = p.commitCommands.get(1);
assertTrue(commit.optimize);
assertFalse(commit.waitSearcher);
assertFalse(commit.openSearcher);
// DELETE COMMANDS
assertEquals(4, p.deleteCommands.size());
DeleteUpdateCommand delete = p.deleteCommands.get(0);
assertEquals(delete.id, "ID");
assertEquals(delete.query, null);
assertEquals(delete.commitWithin, -1);
delete = p.deleteCommands.get(1);
assertEquals(delete.id, "ID");
assertEquals(delete.query, null);
assertEquals(delete.commitWithin, 500);
delete = p.deleteCommands.get(2);
assertEquals(delete.id, null);
assertEquals(delete.query, "QUERY");
assertEquals(delete.commitWithin, -1);
delete = p.deleteCommands.get(3);
assertEquals(delete.id, null);
assertEquals(delete.query, "QUERY");
assertEquals(delete.commitWithin, 500);
// ROLLBACK COMMANDS
assertEquals(1, p.rollbackCommands.size());
req.close();
}
use of org.apache.solr.update.DeleteUpdateCommand in project lucene-solr by apache.
the class DocExpirationUpdateProcessorFactoryTest method testAutomaticDeletes.
public void testAutomaticDeletes() throws Exception {
// get a handle on our recorder
UpdateRequestProcessorChain chain = h.getCore().getUpdateProcessingChain("scheduled-delete");
assertNotNull(chain);
List<UpdateRequestProcessorFactory> factories = chain.getProcessors();
assertEquals("did number of processors configured in chain get changed?", 5, factories.size());
assertTrue("Expected [1] RecordingUpdateProcessorFactory: " + factories.get(1).getClass(), factories.get(1) instanceof RecordingUpdateProcessorFactory);
RecordingUpdateProcessorFactory recorder = (RecordingUpdateProcessorFactory) factories.get(1);
try {
recorder.startRecording();
// more then one iter to verify it's recurring
final int numItersToCheck = 1 + RANDOM_MULTIPLIER;
for (int i = 0; i < numItersToCheck; i++) {
UpdateCommand tmp;
// be generous in how long we wait, some jenkins machines are slooooow
tmp = recorder.commandQueue.poll(30, TimeUnit.SECONDS);
// we can be confident in the order because DocExpirationUpdateProcessorFactory
// uses the same request for both the delete & the commit -- and both
// RecordingUpdateProcessorFactory's getInstance & startRecording methods are
// synchronized. So it should not be possible to start recording in the
// middle of the two commands
assertTrue("expected DeleteUpdateCommand: " + tmp.getClass(), tmp instanceof DeleteUpdateCommand);
DeleteUpdateCommand delete = (DeleteUpdateCommand) tmp;
assertFalse(delete.isDeleteById());
assertNotNull(delete.getQuery());
assertTrue(delete.getQuery(), delete.getQuery().startsWith("{!cache=false}eXpField_tdt:[* TO "));
// commit should be immediately after the delete
tmp = recorder.commandQueue.poll(5, TimeUnit.SECONDS);
assertTrue("expected CommitUpdateCommand: " + tmp.getClass(), tmp instanceof CommitUpdateCommand);
CommitUpdateCommand commit = (CommitUpdateCommand) tmp;
assertTrue(commit.softCommit);
assertTrue(commit.openSearcher);
}
} finally {
recorder.stopRecording();
}
}
use of org.apache.solr.update.DeleteUpdateCommand in project lucene-solr by apache.
the class UpdateProcessorTestBase method processDeleteById.
protected void processDeleteById(final String chain, String id) 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());
DeleteUpdateCommand cmd = new DeleteUpdateCommand(req);
cmd.setId(id);
UpdateRequestProcessor processor = pc.createProcessor(req, rsp);
try {
processor.processDelete(cmd);
} finally {
req.close();
}
}
Aggregations