use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class FullSolrCloudDistribCmdsTest method addTwoDocsInOneRequest.
private long addTwoDocsInOneRequest(long docId) throws Exception {
QueryResponse results;
UpdateRequest uReq;
uReq = new UpdateRequest();
docId = addDoc(docId, uReq);
docId = addDoc(docId, uReq);
uReq.process(cloudClient);
uReq.process(controlClient);
commit();
checkShardConsistency();
assertDocCounts(VERBOSE);
results = query(cloudClient);
assertEquals(2, results.getResults().getNumFound());
return docId;
}
use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class FullSolrCloudDistribCmdsTest method testOptimisticUpdate.
private void testOptimisticUpdate(QueryResponse results) throws Exception {
SolrDocument doc = results.getResults().get(0);
Long version = (Long) doc.getFieldValue(VERSION_FIELD);
Integer theDoc = (Integer) doc.getFieldValue("id");
UpdateRequest uReq = new UpdateRequest();
SolrInputDocument doc1 = new SolrInputDocument();
uReq.setParams(new ModifiableSolrParams());
uReq.getParams().set(VERSION_FIELD, Long.toString(version));
addFields(doc1, "id", theDoc, t1, "theupdatestuff");
uReq.add(doc1);
uReq.process(cloudClient);
uReq.process(controlClient);
commit();
// updating the old version should fail...
SolrInputDocument doc2 = new SolrInputDocument();
uReq = new UpdateRequest();
uReq.setParams(new ModifiableSolrParams());
uReq.getParams().set(VERSION_FIELD, Long.toString(version));
addFields(doc2, "id", theDoc, t1, "thenewupdatestuff");
uReq.add(doc2);
uReq.process(cloudClient);
uReq.process(controlClient);
commit();
ModifiableSolrParams params = new ModifiableSolrParams();
params.add("q", t1 + ":thenewupdatestuff");
QueryResponse res = clients.get(0).query(params);
assertEquals(0, res.getResults().getNumFound());
params = new ModifiableSolrParams();
params.add("q", t1 + ":theupdatestuff");
res = clients.get(0).query(params);
assertEquals(1, res.getResults().getNumFound());
}
use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class FullSolrCloudDistribCmdsTest method testConcurrentIndexing.
private long testConcurrentIndexing(long docId) throws Exception {
QueryResponse results = query(cloudClient);
long beforeCount = results.getResults().getNumFound();
int cnt = TEST_NIGHTLY ? 2933 : 313;
try (ConcurrentUpdateSolrClient concurrentClient = getConcurrentUpdateSolrClient(((HttpSolrClient) clients.get(0)).getBaseURL(), 10, 2)) {
concurrentClient.setConnectionTimeout(120000);
for (int i = 0; i < cnt; i++) {
index_specific(concurrentClient, id, docId++, "text_t", "some text so that it not's negligent work to parse this doc, even though it's still a pretty short doc");
}
concurrentClient.blockUntilFinished();
commit();
checkShardConsistency();
assertDocCounts(VERBOSE);
}
results = query(cloudClient);
assertEquals(beforeCount + cnt, results.getResults().getNumFound());
return docId;
}
use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class SegmentTerminateEarlyTestState method queryTimestampAscendingSegmentTerminateEarlyYes.
void queryTimestampAscendingSegmentTerminateEarlyYes(CloudSolrClient cloudSolrClient) throws Exception {
TestMiniSolrCloudCluster.assertFalse(minTimestampDocKeys.isEmpty());
TestMiniSolrCloudCluster.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
final Long oddFieldValue = new Long(minTimestampDocKeys.iterator().next().intValue() % 2);
final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
// a sort order that is _not_ compatible with the merge sort order
query.setSort(TIMESTAMP_FIELD, SolrQuery.ORDER.asc);
query.setFields(KEY_FIELD, ODD_FIELD, TIMESTAMP_FIELD);
query.setRows(1);
query.set(CommonParams.SEGMENT_TERMINATE_EARLY, true);
final QueryResponse rsp = cloudSolrClient.query(query);
// check correctness of the results count
TestMiniSolrCloudCluster.assertEquals("numFound", numDocs / 2, rsp.getResults().getNumFound());
// check correctness of the first result
if (rsp.getResults().getNumFound() > 0) {
final SolrDocument solrDocument0 = rsp.getResults().get(0);
TestMiniSolrCloudCluster.assertTrue(KEY_FIELD + " of (" + solrDocument0 + ") is not in minTimestampDocKeys(" + minTimestampDocKeys + ")", minTimestampDocKeys.contains(solrDocument0.getFieldValue(KEY_FIELD)));
TestMiniSolrCloudCluster.assertEquals(ODD_FIELD, oddFieldValue, solrDocument0.getFieldValue(ODD_FIELD));
}
// check segmentTerminatedEarly flag
TestMiniSolrCloudCluster.assertNotNull("responseHeader.segmentTerminatedEarly missing in " + rsp.getResponseHeader(), rsp.getResponseHeader().get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
// segmentTerminateEarly cannot be used with incompatible sort orders
TestMiniSolrCloudCluster.assertTrue("responseHeader.segmentTerminatedEarly missing/true in " + rsp.getResponseHeader(), Boolean.FALSE.equals(rsp.getResponseHeader().get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
}
use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class SegmentTerminateEarlyTestState method queryTimestampDescending.
void queryTimestampDescending(CloudSolrClient cloudSolrClient) throws Exception {
TestMiniSolrCloudCluster.assertFalse(maxTimestampDocKeys.isEmpty());
TestMiniSolrCloudCluster.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
final Long oddFieldValue = new Long(maxTimestampDocKeys.iterator().next().intValue() % 2);
final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
query.setSort(TIMESTAMP_FIELD, SolrQuery.ORDER.desc);
query.setFields(KEY_FIELD, ODD_FIELD, TIMESTAMP_FIELD);
query.setRows(1);
// CommonParams.SEGMENT_TERMINATE_EARLY parameter intentionally absent
final QueryResponse rsp = cloudSolrClient.query(query);
// check correctness of the results count
TestMiniSolrCloudCluster.assertEquals("numFound", numDocs / 2, rsp.getResults().getNumFound());
// check correctness of the first result
if (rsp.getResults().getNumFound() > 0) {
final SolrDocument solrDocument0 = rsp.getResults().get(0);
TestMiniSolrCloudCluster.assertTrue(KEY_FIELD + " of (" + solrDocument0 + ") is not in maxTimestampDocKeys(" + maxTimestampDocKeys + ")", maxTimestampDocKeys.contains(solrDocument0.getFieldValue(KEY_FIELD)));
TestMiniSolrCloudCluster.assertEquals(ODD_FIELD, oddFieldValue, solrDocument0.getFieldValue(ODD_FIELD));
}
// check segmentTerminatedEarly flag
TestMiniSolrCloudCluster.assertNull("responseHeader.segmentTerminatedEarly present in " + rsp.getResponseHeader(), rsp.getResponseHeader().get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
}
Aggregations