use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestInPlaceUpdatesDistrib method updatingDVsInAVeryOldSegment.
/**
* Ingest many documents, keep committing. Then update a document from a very old segment.
*/
private void updatingDVsInAVeryOldSegment() throws Exception {
clearIndex();
commit();
String id = String.valueOf(Integer.MAX_VALUE);
index("id", id, "inplace_updatable_float", "1", "title_s", "newtitle");
// create 10 more segments
for (int i = 0; i < 10; i++) {
buildRandomIndex(101.0F, Collections.emptyList());
}
index("id", id, "inplace_updatable_float", map("inc", "1"));
for (SolrClient client : new SolrClient[] { LEADER, NONLEADERS.get(0), NONLEADERS.get(1) }) {
assertEquals("newtitle", client.getById(id).get("title_s"));
assertEquals(2.0f, client.getById(id).get("inplace_updatable_float"));
}
commit();
for (SolrClient client : new SolrClient[] { LEADER, NONLEADERS.get(0), NONLEADERS.get(1) }) {
assertEquals("newtitle", client.getById(id).get("title_s"));
assertEquals(2.0f, client.getById(id).get("inplace_updatable_float"));
}
log.info("updatingDVsInAVeryOldSegment: This test passed fine...");
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestInPlaceUpdatesDistrib method clearIndex.
@Override
public void clearIndex() {
super.clearIndex();
try {
for (SolrClient client : new SolrClient[] { LEADER, NONLEADERS.get(0), NONLEADERS.get(1) }) {
if (client != null) {
client.request(simulatedDeleteRequest("*:*", -Long.MAX_VALUE));
client.commit();
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class NoOpResponseParserTest method doBefore.
@Before
public void doBefore() throws IOException, SolrServerException {
//add document and commit, and ensure it's there
SolrClient client = getSolrClient();
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "1234");
client.add(doc);
client.commit();
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class BaseDistributedSearchTestCase method query.
/**
* Returns the QueryResponse from {@link #queryServer}
*/
protected QueryResponse query(boolean setDistribParams, SolrParams p) throws Exception {
final ModifiableSolrParams params = new ModifiableSolrParams(p);
// TODO: look into why passing true causes fails
params.set("distrib", "false");
final QueryResponse controlRsp = controlClient.query(params);
validateControlData(controlRsp);
params.remove("distrib");
if (setDistribParams)
setDistributedParams(params);
QueryResponse rsp = queryServer(params);
compareResponses(rsp, controlRsp);
if (stress > 0) {
log.info("starting stress...");
Thread[] threads = new Thread[nThreads];
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread() {
@Override
public void run() {
for (int j = 0; j < stress; j++) {
int which = r.nextInt(clients.size());
SolrClient client = clients.get(which);
try {
QueryResponse rsp = client.query(new ModifiableSolrParams(params));
if (verifyStress) {
compareResponses(rsp, controlRsp);
}
} catch (SolrServerException | IOException e) {
throw new RuntimeException(e);
}
}
}
};
threads[i].start();
}
for (Thread thread : threads) {
thread.join();
}
}
return rsp;
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestRandomFlRTGCloud method addRandomDocument.
/**
* Adds one randomly generated document with the specified docId, asserting success, and returns
* the document added
*/
private SolrInputDocument addRandomDocument(final int docId) throws IOException, SolrServerException {
final SolrClient client = getRandClient(random());
final SolrInputDocument doc = sdoc("id", "" + docId, "aaa_i", random().nextInt(), "bbb_i", random().nextInt(), //
"ccc_s", TestUtil.randomSimpleString(random()), "ddd_s", TestUtil.randomSimpleString(random()), "eee_s", TestUtil.randomSimpleString(random()), "fff_s", TestUtil.randomSimpleString(random()), "ggg_s", TestUtil.randomSimpleString(random()), "hhh_s", TestUtil.randomSimpleString(random()), //
"geo_1_srpt", GeoTransformerValidator.getValueForIndexing(random()), "geo_2_srpt", GeoTransformerValidator.getValueForIndexing(random()), // for testing subqueries
"next_2_ids_ss", String.valueOf(docId + 1), "next_2_ids_ss", String.valueOf(docId + 2), // for testing prefix globbing
"axx_i", random().nextInt(), "ayy_i", random().nextInt(), "azz_s", TestUtil.randomSimpleString(random()));
log.info("ADD: {} = {}", docId, doc);
assertEquals(0, client.add(doc).getStatus());
return doc;
}
Aggregations