/// <summary> /// we fake a float test using int2float conversion of NumericUtils </summary> private void TestFloatRange(int precisionStep) { string field = "ascfield" + precisionStep; const int lower = -1000, upper = +2000; Query tq = NumericRangeQuery.NewFloatRange(field, precisionStep, NumericUtils.SortableIntToFloat(lower), NumericUtils.SortableIntToFloat(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.NewFloatRange(field, precisionStep, NumericUtils.SortableIntToFloat(lower), NumericUtils.SortableIntToFloat(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 float test using int2float conversion of NumericUtils </summary> private void TestFloatRange(int precisionStep) { System.String field = "ascfield" + precisionStep; int lower = -1000; int upper = +2000; System.Single tempAux = (float)NumericUtils.SortableIntToFloat(lower); System.Single tempAux2 = (float)NumericUtils.SortableIntToFloat(upper); Query tq = NumericRangeQuery.NewFloatRange(field, precisionStep, tempAux, tempAux2, true, true); TopDocs tTopDocs = searcher.Search(tq, 1, null); Assert.AreEqual(upper - lower + 1, tTopDocs.TotalHits, "Returned count of range query must be equal to inclusive range length"); System.Single tempAux3 = (float)NumericUtils.SortableIntToFloat(lower); System.Single tempAux4 = (float)NumericUtils.SortableIntToFloat(upper); Filter tf = NumericRangeFilter.NewFloatRange(field, precisionStep, tempAux3, tempAux4, true, true); tTopDocs = searcher.Search((Query) new MatchAllDocsQuery(), tf, (int)1, (IState)null); Assert.AreEqual(upper - lower + 1, tTopDocs.TotalHits, "Returned count of range filter must be equal to inclusive range length"); }