Exemple #1
0
 public Int32DocValuesAnonymousClass(ReverseOrdFieldSource @this, int off, SortedDocValues sindex, int end)
     : base(@this)
 {
     this.off    = off;
     this.sindex = sindex;
     this.end    = end;
 }
Exemple #2
0
 public Int32DocValuesAnonymousInnerClassHelper(ReverseOrdFieldSource outerInstance, ReverseOrdFieldSource @this, int off, SortedDocValues sindex, int end)
     : base(@this)
 {
     this.outerInstance = outerInstance;
     this.off           = off;
     this.sindex        = sindex;
     this.end           = end;
 }
Exemple #3
0
        public void TestEqualsNull()
        {
            OrdFieldSource ofs = new OrdFieldSource("f");
            assertFalse(ofs.Equals(null));

            ReverseOrdFieldSource rofs = new ReverseOrdFieldSource("f");
            assertFalse(rofs.Equals(null));
        }
 public IntDocValuesAnonymousInnerClassHelper(ReverseOrdFieldSource outerInstance, ReverseOrdFieldSource @this, int off, SortedDocValues sindex, int end)
     : base(@this)
 {
     this.outerInstance = outerInstance;
     this.off = off;
     this.sindex = sindex;
     this.end = end;
 }
        /// <summary>
        /// Test that queries based on reverse/ordFieldScore scores correctly
        /// </summary>
        /// <param name="field"></param>
        /// <param name="inOrder"></param>
        private void DoTestRank(string field, bool inOrder)
        {
            IndexReader r = DirectoryReader.Open(dir);
            IndexSearcher s = NewSearcher(r);
            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, Similarity);
            ScoreDoc[] h = s.Search(q, null, 1000).ScoreDocs;
            assertEquals("All docs should be matched!", N_DOCS, h.Length);
            string prevID = inOrder ? "IE" : "IC"; // smaller than all ids of docs in this test ("ID0001", etc.) -  greater 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.Dispose();
        }
Exemple #6
0
 /// <summary>
 /// Test that queries based on reverse/ordFieldScore returns docs with expected score.
 /// </summary>
 /// <param name="field"></param>
 /// <param name="inOrder"></param>
 private void DoTestExactScore(string field, bool inOrder)
 {
     IndexReader r = DirectoryReader.Open(dir);
     IndexSearcher s = NewSearcher(r);
     ValueSource vs;
     if (inOrder)
     {
         vs = new OrdFieldSource(field);
     }
     else
     {
         vs = new ReverseOrdFieldSource(field);
     }
     Query q = new FunctionQuery(vs);
     TopDocs td = s.Search(q, null, 1000);
     assertEquals("All docs should be matched!", N_DOCS, td.TotalHits);
     ScoreDoc[] sd = td.ScoreDocs;
     for (int i = 0; i < sd.Length; i++)
     {
         float score = sd[i].Score;
         string id = s.IndexReader.Document(sd[i].Doc).Get(ID_FIELD);
         Log("-------- " + i + ". Explain doc " + id);
         Log(s.Explain(q, sd[i].Doc));
         float expectedScore = N_DOCS - i - 1;
         assertEquals("score of result " + i + " shuould be " + expectedScore + " != " + score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
         string expectedId = inOrder ? Id2String(N_DOCS - i) : Id2String(i + 1); // reverse  ==> smaller values first -  in-order ==> larger  values first
         assertTrue("id of result " + i + " shuould be " + expectedId + " != " + score, expectedId.Equals(id));
     }
     r.Dispose();
 }