public void testSimpleEqualScores2() throws Exception { DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.0f); q.add(tq("dek", "albino")); q.add(tq("dek", "elephant")); QueryUtils.check(q, s); ScoreDoc[] h = s.search(q, null, 1000).scoreDocs; try { assertEquals("3 docs should match " + q.toString(), 3, h.length); float score = h[0].score; for (int i = 1; i < h.length; i++) { assertEquals("score #" + i + " is not the same", score, h[i].score, SCORE_COMP_THRESH); } } catch (Error e) { printHits("testSimpleEqualScores2", h, s); throw e; } }
public void testSimpleTiebreaker() throws Exception { DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.01f); q.add(tq("dek", "albino")); q.add(tq("dek", "elephant")); QueryUtils.check(q, s); ScoreDoc[] h = s.search(q, null, 1000).scoreDocs; try { assertEquals("3 docs should match " + q.toString(), 3, h.length); assertEquals("wrong first", "d2", s.doc(h[0].doc).get("id")); float score0 = h[0].score; float score1 = h[1].score; float score2 = h[2].score; assertTrue( "d2 does not have better score then others: " + score0 + " >? " + score1, score0 > score1); assertEquals("d4 and d1 don't have equal scores", score1, score2, SCORE_COMP_THRESH); } catch (Error e) { printHits("testSimpleTiebreaker", h, s); throw e; } }