CheckHitsQuery() public static method

Tests that two queries have an expected order of documents, and that the two queries have the same score values.
public static CheckHitsQuery ( Query query, Lucene.Net.Search.ScoreDoc hits1, Lucene.Net.Search.ScoreDoc hits2, int results ) : void
query Query
hits1 Lucene.Net.Search.ScoreDoc
hits2 Lucene.Net.Search.ScoreDoc
results int
return void
Beispiel #1
0
        public virtual void QueriesTest(Query query, int[] expDocNrs)
        {
            TopScoreDocCollector collector = TopScoreDocCollector.Create(1000, false);

            Searcher.Search(query, null, collector);
            ScoreDoc[] hits1 = collector.GetTopDocs().ScoreDocs;

            collector = TopScoreDocCollector.Create(1000, true);
            Searcher.Search(query, null, collector);
            ScoreDoc[] hits2 = collector.GetTopDocs().ScoreDocs;

            Assert.AreEqual(MulFactor * collector.TotalHits, BigSearcher.Search(query, 1).TotalHits);

            CheckHits.CheckHitsQuery(query, hits1, hits2, expDocNrs);
        }
Beispiel #2
0
        public virtual void QueriesTest(System.String queryText, int[] expDocNrs)
        {
            //System.out.println();
            //System.out.println("Query: " + queryText);
            Query query1 = MakeQuery(queryText);
            TopScoreDocCollector collector = TopScoreDocCollector.Create(1000, false);

            searcher.Search(query1, null, collector, null);
            ScoreDoc[] hits1 = collector.TopDocs().ScoreDocs;

            Query query2 = MakeQuery(queryText); // there should be no need to parse again...

            collector = TopScoreDocCollector.Create(1000, true);
            searcher.Search(query2, null, collector, null);
            ScoreDoc[] hits2 = collector.TopDocs().ScoreDocs;

            Assert.AreEqual(mulFactor * collector.internalTotalHits, bigSearcher.Search(query1, 1, null).TotalHits);

            CheckHits.CheckHitsQuery(query2, hits1, hits2, expDocNrs);
        }
Beispiel #3
0
        public virtual void  QueriesTest(System.String queryText, int[] expDocNrs)
        {
            //System.out.println();
            //System.out.println("Query: " + queryText);
            try
            {
                Query query1 = MakeQuery(queryText);
                BooleanQuery.SetAllowDocsOutOfOrder(true);
                ScoreDoc[] hits1 = searcher.Search(query1, null, 1000).scoreDocs;

                Query query2 = MakeQuery(queryText);                 // there should be no need to parse again...
                BooleanQuery.SetAllowDocsOutOfOrder(false);
                ScoreDoc[] hits2 = searcher.Search(query2, null, 1000).scoreDocs;

                CheckHits.CheckHitsQuery(query2, hits1, hits2, expDocNrs);
            }
            finally
            {
                // even when a test fails.
                BooleanQuery.SetAllowDocsOutOfOrder(false);
            }
        }