Example #1
0
        /// <summary>
        /// we fake a double test using long2double conversion of NumericUtils </summary>
        private void TestDoubleRange(int precisionStep)
        {
            string     field = "ascfield" + precisionStep;
            const long lower = -1000L, upper = +2000L;

            Query   tq       = NumericRangeQuery.NewDoubleRange(field, precisionStep, NumericUtils.SortableInt64ToDouble(lower), NumericUtils.SortableInt64ToDouble(upper), true, true);
            TopDocs tTopDocs = Searcher.Search(tq, 1);

            Assert.AreEqual(upper - lower + 1, tTopDocs.TotalHits, "Returned count of range query must be equal to inclusive range length");

            Filter tf = NumericRangeFilter.NewDoubleRange(field, precisionStep, NumericUtils.SortableInt64ToDouble(lower), NumericUtils.SortableInt64ToDouble(upper), true, true);

            tTopDocs = Searcher.Search(new MatchAllDocsQuery(), tf, 1);
            Assert.AreEqual(upper - lower + 1, tTopDocs.TotalHits, "Returned count of range filter must be equal to inclusive range length");
        }
        /// <summary>we fake a double test using long2double conversion of NumericUtils </summary>
        private void  TestDoubleRange(int precisionStep)
        {
            System.String field = "ascfield" + precisionStep;
            long          lower = -1000L;
            long          upper = +2000L;

            System.Double tempAux  = (double)NumericUtils.SortableLongToDouble(lower);
            System.Double tempAux2 = (double)NumericUtils.SortableLongToDouble(upper);
            Query         tq       = NumericRangeQuery.NewDoubleRange(field, precisionStep, tempAux, tempAux2, true, true);
            TopDocs       tTopDocs = searcher.Search(tq, 1);

            Assert.AreEqual(upper - lower + 1, tTopDocs.totalHits, "Returned count of range query must be equal to inclusive range length");

            System.Double tempAux3 = (double)NumericUtils.SortableLongToDouble(lower);
            System.Double tempAux4 = (double)NumericUtils.SortableLongToDouble(upper);
            Filter        tf       = NumericRangeFilter.NewDoubleRange(field, precisionStep, tempAux3, tempAux4, true, true);

            tTopDocs = searcher.Search(new MatchAllDocsQuery(), tf, 1);
            Assert.AreEqual(upper - lower + 1, tTopDocs.totalHits, "Returned count of range filter must be equal to inclusive range length");
        }