use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class UpdateLogTest method ulogCommit.
/**
* Simulate a commit on a given updateLog
*/
private static void ulogCommit(UpdateLog ulog) {
try (SolrQueryRequest req = req()) {
CommitUpdateCommand commitCmd = new CommitUpdateCommand(req, false);
ulog.preCommit(commitCmd);
ulog.postCommit(commitCmd);
}
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class UpdateLogTest method ulogAdd.
/**
* Simulate an add on a given updateLog.
* <p>
* This method, when prevVersion is passed in (i.e. for in-place update), represents an
* AddUpdateCommand that has undergone the merge process and inc/set operations have now been
* converted into actual values that just need to be written.
* </p>
* <p>
* NOTE: For test simplicity, the Solr input document must include the <code>_version_</code> field.
* </p>
*
* @param ulog The UpdateLog to apply a delete against
* @param prevVersion If non-null, then this AddUpdateCommand represents an in-place update.
* @param sdoc The document to use for the add.
* @see #buildAddUpdateCommand
*/
private static void ulogAdd(UpdateLog ulog, Long prevVersion, SolrInputDocument sdoc) {
try (SolrQueryRequest req = req()) {
AddUpdateCommand cmd = buildAddUpdateCommand(req, sdoc);
if (prevVersion != null) {
cmd.prevVersion = prevVersion;
}
ulog.add(cmd);
}
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class ClassificationUpdateProcessorFactoryTest method init_unsupportedFilterQuery_shouldThrowExceptionWithDetailedMessage.
@Test
public void init_unsupportedFilterQuery_shouldThrowExceptionWithDetailedMessage() {
UpdateRequestProcessor mockProcessor = mock(UpdateRequestProcessor.class);
SolrQueryRequest mockRequest = mock(SolrQueryRequest.class);
SolrQueryResponse mockResponse = mock(SolrQueryResponse.class);
args.add("knn.filterQuery", "not supported query");
try {
cFactoryToTest.init(args);
/* parsing failure happens because of the mocks, fine enough to check a proper exception propagation */
cFactoryToTest.getInstance(mockRequest, mockResponse, mockProcessor);
} catch (SolrException e) {
assertEquals("Classification UpdateProcessor Training Filter Query: 'not supported query' is not supported", e.getMessage());
}
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class ClassificationUpdateProcessorIntegrationTest method getDoc.
private Document getDoc(String id) throws IOException {
try (SolrQueryRequest req = req()) {
SolrIndexSearcher searcher = req.getSearcher();
TermQuery query = new TermQuery(new Term(ID, id));
TopDocs doc1 = searcher.search(query, 1);
ScoreDoc scoreDoc = doc1.scoreDocs[0];
return searcher.doc(scoreDoc.doc);
}
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class TestIndexingPerformance method testIndexingPerf.
public void testIndexingPerf() throws IOException {
int iter = 1000;
String iterS = System.getProperty("iter");
if (iterS != null)
iter = Integer.parseInt(iterS);
boolean overwrite = Boolean.parseBoolean(System.getProperty("overwrite", "false"));
String doc = System.getProperty("doc");
if (doc != null) {
StrUtils.splitSmart(doc, ",", true);
}
SolrQueryRequest req = lrf.makeRequest();
UpdateHandler updateHandler = req.getCore().getUpdateHandler();
String field = "textgap";
String[] fields = { field, "simple", field, "test", field, "how now brown cow", field, "what's that?", field, "radical!", field, "what's all this about, anyway?", field, "just how fast is this text indexing?" };
/***
String[] fields = {
"a_i","1"
,"b_i","2"
,"c_i","3"
,"d_i","4"
,"e_i","5"
,"f_i","6"
,"g_i","7"
,"h_i","8"
,"i_i","9"
,"j_i","0"
,"k_i","0"
};
***/
final RTimer timer = new RTimer();
AddUpdateCommand add = new AddUpdateCommand(req);
add.overwrite = overwrite;
for (int i = 0; i < iter; i++) {
add.clear();
add.solrDoc = new SolrInputDocument();
add.solrDoc.addField("id", Integer.toString(i));
for (int j = 0; j < fields.length; j += 2) {
String f = fields[j];
String val = fields[j + 1];
add.solrDoc.addField(f, val);
}
updateHandler.addDoc(add);
}
log.info("doc=" + Arrays.toString(fields));
double elapsed = timer.getTime();
log.info("iter=" + iter + " time=" + elapsed + " throughput=" + ((long) iter * 1000) / elapsed);
//discard all the changes
updateHandler.rollback(new RollbackUpdateCommand(req));
req.close();
}
Aggregations