The numeric range query finds documents containing a numeric value in the specified field within the specified range. Either min or max can be omitted, but not both.
Inheritance: FtsQueryBase
コード例 #1
0
        public void Export_Omits_Field_If_Not_Provided()
        {
            var query = new NumericRangeQuery()
                .Min(1)
                .Max(10);

            var expected = JsonConvert.SerializeObject(new
            {
                min = 1.0,
                inclusive_min = true,
                max = 10.0,
                inclusive_max = false
            }, Formatting.None);

            Assert.AreEqual(expected, query.Export().ToString(Formatting.None));
        }
コード例 #2
0
        public void Export_Returns_Valud_Json()
        {
            var query = new NumericRangeQuery()
                .Min(1)
                .Max(10)
                .Field("field");

            var expected = JsonConvert.SerializeObject(new
            {
                min = 1.0,
                inclusive_min = true,
                max = 10.0,
                inclusive_max = false,
                field = "field"
            }, Formatting.None);

            Assert.AreEqual(expected, query.Export().ToString(Formatting.None));
        }
コード例 #3
0
        public void Boost_WhenBoostIsLessThanZero_ThrowsArgumentOutOfRangeException()
        {
            var query = new NumericRangeQuery();

            Assert.Throws<ArgumentOutOfRangeException>(() => query.Boost(-.1));
        }
コード例 #4
0
        public void Boost_Returns_NumericRangeQuery()
        {
            var query = new NumericRangeQuery().Boost(2.2);

            Assert.IsInstanceOf<NumericRangeQuery> (query);
        }