Ejemplo n.º 1
0
 public void TestConstantScoreWithRangeFilter()
 {
     var termFilter = new RangeFilter("age", "22","25",true,true);
     var constanFilter = new ConstantScoreQuery(termFilter);
     var result2 = client.Search(index, "type", constanFilter, 0, 5);
     Assert.AreEqual(4, result2.GetTotalCount());
     Assert.AreEqual(4, result2.GetHits().Hits.Count);
 }
Ejemplo n.º 2
0
        public void TestConstantScoreNestedAndFilter()
        {

            IFilter termFilter = new TermFilter("gender", "true");

            var andFilter = new AndFilter(termFilter);
            
            var constanFilter = new ConstantScoreQuery(andFilter);
            
            var result2 = client.Search(index, "type", constanFilter, 0, 5);
            Assert.AreEqual(50, result2.GetTotalCount());
            Assert.AreEqual(5, result2.GetHits().Hits.Count);


            //test and filter and range filter

            termFilter = new RangeFilter("age", "22", "25", true, true);

            andFilter = new AndFilter(termFilter);

            constanFilter = new ConstantScoreQuery(andFilter);
            result2 = client.Search(index, "type", constanFilter, 0, 5);
            Assert.AreEqual(4, result2.GetTotalCount());
            Assert.AreEqual(4, result2.GetHits().Hits.Count);


            //test bool filter and range filter
            termFilter = new RangeFilter("age", "22", "25", true, true);

            var boolfilter = new BoolFilter();
            boolfilter.Must(termFilter);

            constanFilter = new ConstantScoreQuery(boolfilter);
            result2 = client.Search(index, "type", constanFilter, 0, 5);
            Assert.AreEqual(4, result2.GetTotalCount());
            Assert.AreEqual(4, result2.GetHits().Hits.Count);


        }
Ejemplo n.º 3
0
		public void TestRangeFilter()
		{
			var rangefilter = new RangeFilter("age", "22", "25", true, true);
			ConstantScoreQuery query = new ConstantScoreQuery(rangefilter);

			var result = client.Search(index, "type" , query, 0, 5);

			Assert.AreEqual(4, result.GetTotalCount());


			rangefilter = new RangeFilter("age", "22", "25", false, true);
			query = new ConstantScoreQuery(rangefilter);

			result = client.Search(index, "type" , query, 0, 5);

			Assert.AreEqual(3, result.GetTotalCount());

			rangefilter = new RangeFilter("age", "22", "25", false, false);
			query = new ConstantScoreQuery(rangefilter);

			result = client.Search(index, "type" , query, 0, 5);

			Assert.AreEqual(2, result.GetTotalCount());
		}