List of usage examples for org.apache.lucene.search QueryUtils check
public static void check(Random random, Query q1, IndexSearcher s)
From source file:org.apache.solr.search.function.TestOrdValues.java
License:Apache License
private void doTestRank(String field, boolean inOrder) throws Exception { IndexReader r = DirectoryReader.open(dir); IndexSearcher s = newSearcher(r);//from w w w . j a v a 2 s. c om ValueSource vs; if (inOrder) { vs = new OrdFieldSource(field); } else { vs = new ReverseOrdFieldSource(field); } Query q = new FunctionQuery(vs); log("test: " + q); QueryUtils.check(random(), q, s); ScoreDoc[] h = s.search(q, 1000).scoreDocs; assertEquals("All docs should be matched!", N_DOCS, h.length); String prevID = inOrder ? "IE" // greater than all ids of docs in this test ("ID0001", etc.) : "IC"; // smaller than all ids of docs in this test ("ID0001", etc.) for (int i = 0; i < h.length; i++) { String resID = s.doc(h[i].doc).get(ID_FIELD); log(i + ". score=" + h[i].score + " - " + resID); log(s.explain(q, h[i].doc)); if (inOrder) { assertTrue("res id " + resID + " should be < prev res id " + prevID, resID.compareTo(prevID) < 0); } else { assertTrue("res id " + resID + " should be > prev res id " + prevID, resID.compareTo(prevID) > 0); } prevID = resID; } r.close(); }