use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class DistribCursorPagingTest method assertFullWalkNoDups.
/**
* <p>
* Given a set of params, executes a cursor query using {@link CursorMarkParams#CURSOR_MARK_START}
* and then continuously walks the results using {@link CursorMarkParams#CURSOR_MARK_START} as long
* as a non-0 number of docs ar returned. This method records the the set of all id's
* (must be positive ints) encountered and throws an assertion failure if any id is
* encountered more then once, or if the set grows above maxSize
* </p>
*
* <p>
* Note that this method explicitly uses the "cloudClient" for executing the queries,
* instead of relying on the test infrastructure to execute the queries redundently
* against both the cloud client as well as a control client. This is because term stat
* differences in a sharded setup can result in different scores for documents compared
* to the control index -- which can affect the sorting in some cases and cause false
* negatives in the response comparisons (even if we don't include "score" in the "fl")
* </p>
*/
public SentinelIntSet assertFullWalkNoDups(int maxSize, SolrParams params) throws Exception {
SentinelIntSet ids = new SentinelIntSet(maxSize, -1);
String cursorMark = CURSOR_MARK_START;
int docsOnThisPage = Integer.MAX_VALUE;
while (0 < docsOnThisPage) {
final SolrParams p = p(params, CURSOR_MARK_PARAM, cursorMark);
QueryResponse rsp = cloudClient.query(p);
String nextCursorMark = assertHashNextCursorMark(rsp);
SolrDocumentList docs = extractDocList(rsp);
docsOnThisPage = docs.size();
if (null != params.getInt(CommonParams.ROWS)) {
int rows = params.getInt(CommonParams.ROWS);
assertTrue("Too many docs on this page: " + rows + " < " + docsOnThisPage, docsOnThisPage <= rows);
}
if (0 == docsOnThisPage) {
assertEquals("no more docs, but " + CURSOR_MARK_NEXT + " isn't same", cursorMark, nextCursorMark);
}
for (SolrDocument doc : docs) {
int id = ((Integer) doc.get("id")).intValue();
if (ids.exists(id)) {
String msg = "(" + p + ") walk already seen: " + id;
try {
queryAndCompareShards(params("distrib", "false", "q", "id:" + id));
} catch (AssertionError ae) {
throw new AssertionError(msg + ", found shard inconsistency that would explain it...", ae);
}
rsp = cloudClient.query(params("q", "id:" + id));
throw new AssertionError(msg + ", don't know why; q=id:" + id + " gives: " + rsp.toString());
}
ids.put(id);
assertFalse("id set bigger then max allowed (" + maxSize + "): " + ids.size(), maxSize < ids.size());
}
cursorMark = nextCursorMark;
}
return ids;
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class DistribCursorPagingTest method assertDocList.
/**
* Given a QueryResponse returned by SolrServer.query, asserts that the
* "id" of the list of documents returned matches the expected list
* @see org.apache.solr.client.solrj.SolrClient#query
*/
private void assertDocList(QueryResponse rsp, Object... ids) {
SolrDocumentList docs = extractDocList(rsp);
assertEquals("Wrong number of docs in response", ids.length, docs.size());
int i = 0;
for (Object id : ids) {
assertEquals(rsp.toString(), id, docs.get(i).get("id"));
i++;
}
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class DistribCursorPagingTest method extractDocList.
private SolrDocumentList extractDocList(QueryResponse rsp) {
SolrDocumentList docs = rsp.getResults();
assertNotNull("docList is null", docs);
return docs;
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testFilterAndOneRealFieldRTG.
public void testFilterAndOneRealFieldRTG() throws Exception {
SolrParams params = params("fl", "id,val_i", "fq", "{!field f='subject' v=$my_var}", "my_var", "uncommitted");
SolrDocumentList docs = getRandClient(random()).getById(Arrays.asList("42", "99"), params);
final String msg = params + " => " + docs;
assertEquals(msg, 1, docs.size());
assertEquals(msg, 1, docs.getNumFound());
SolrDocument doc = docs.get(0);
assertEquals(msg, 2, doc.size());
assertEquals(msg, "99", doc.getFieldValue("id"));
assertEquals(msg, 1, doc.getFieldValue("val_i"));
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestCloudInspectUtil method testCheckIfDiffIsLegal.
@Test
public void testCheckIfDiffIsLegal() throws Exception {
Set<String> addFails = null;
Set<String> deleteFails = null;
SolrDocumentList a = getDocList("2", "3");
SolrDocumentList b = getDocList("1");
boolean legal = CloudInspectUtil.checkIfDiffIsLegal(a, b, "control", "cloud", addFails, deleteFails);
assertFalse(legal);
// ################################
addFails = new HashSet<String>();
deleteFails = new HashSet<String>();
a = getDocList("2", "3", "4");
b = getDocList("2", "3");
addFails.add("4");
legal = CloudInspectUtil.checkIfDiffIsLegal(a, b, "control", "cloud", addFails, deleteFails);
assertTrue(legal);
// ################################
addFails = new HashSet<String>();
deleteFails = new HashSet<String>();
a = getDocList("2", "3", "4");
b = getDocList("2", "3", "5");
addFails.add("4");
deleteFails.add("5");
legal = CloudInspectUtil.checkIfDiffIsLegal(a, b, "control", "cloud", addFails, deleteFails);
assertTrue(legal);
// ################################
addFails = new HashSet<String>();
deleteFails = new HashSet<String>();
a = getDocList("2", "3", "4");
b = getDocList("2", "3", "5");
addFails.add("4");
deleteFails.add("6");
legal = CloudInspectUtil.checkIfDiffIsLegal(a, b, "control", "cloud", addFails, deleteFails);
assertFalse(legal);
// ################################
addFails = new HashSet<String>();
deleteFails = new HashSet<String>();
a = getDocList("2", "3", "4");
b = getDocList("2", "3", "4");
try {
legal = CloudInspectUtil.checkIfDiffIsLegal(a, b, "control", "cloud", addFails, deleteFails);
fail("Expected exception because lists have no diff");
} catch (IllegalArgumentException e) {
// expected
}
}
Aggregations