private void checkQuery(IndexSearcher @is, Query query, int doc, int maxTopN) { for (int n = 1; n < maxTopN; n++) { CheckQueryPostingsHighlighter p1 = new CheckQueryPostingsHighlighter(int.MaxValue - 1); CheckQueryPostingsHighlighter p2 = new CheckQueryPostingsHighlighter(int.MaxValue - 1); // FakePassageFormatter f1 = new FakePassageFormatter(); // PostingsHighlighter p1 = new PostingsHighlighter(int.MaxValue - 1) { // @Override // protected PassageFormatter getFormatter(String field) //{ // assertEquals("body", field); // return f1; //} // }; // FakePassageFormatter f2 = new FakePassageFormatter(); //PostingsHighlighter p2 = new PostingsHighlighter(Integer.MAX_VALUE - 1) { // @Override // protected PassageFormatter getFormatter(String field) //{ // assertEquals("body", field); // return f2; //} // }; BooleanQuery bq = new BooleanQuery(false); bq.Add(query, Occur.MUST); bq.Add(new TermQuery(new Term("id", Number.ToString(doc))), Occur.MUST); TopDocs td = @is.Search(bq, 1); p1.Highlight("body", bq, @is, td, n); p2.Highlight("body", bq, @is, td, n + 1); assertTrue(p2.f.seen.containsAll(p1.f.seen)); } }
private void checkQuery(IndexSearcher @is, Query query, int doc, int maxTopN) { for (int n = 1; n < maxTopN; n++) { CheckQueryPostingsHighlighter p1 = new CheckQueryPostingsHighlighter(int.MaxValue - 1); CheckQueryPostingsHighlighter p2 = new CheckQueryPostingsHighlighter(int.MaxValue - 1); BooleanQuery bq = new BooleanQuery(false); bq.Add(query, Occur.MUST); bq.Add(new TermQuery(new Term("id", Number.ToString(doc))), Occur.MUST); TopDocs td = @is.Search(bq, 1); p1.Highlight("body", bq, @is, td, n); p2.Highlight("body", bq, @is, td, n + 1); assertTrue(p2.f.seen.containsAll(p1.f.seen)); } }