Esempio n. 1
0
        public void TestBoostFactor_ObjectInitializer_WrongProperty()
        {
            IFunctionScoreFunction boost = new BoostFactorFunction <ElasticsearchProject>(2);

            boost.Weight = 1;
            boost.Filter = new TermFilter {
                Field = Property.Path <ElasticsearchProject>(p => p.Name), Value = "termValue"
            };
            QueryContainer q = new FunctionScoreQuery()
            {
                Weight    = 4,
                Functions = new[] { boost }
            };
            var json     = TestElasticClient.Serialize(q);
            var expected = @"{
                            function_score: {
                              functions : [
                                {
                                    boost_factor: 2.0,
                                    filter:{
                                        term : {
                                            ""name"":""termValue""
                                        }
                                    },
                                    weight: 1.0
                                }
                              ],
                              weight: 4.0
                            }
                        }";

            Assert.True(json.JsonEquals(expected), json);
        }
		public void TestBoostFactor_ObjectInitializer_WrongProperty()
		{
			IFunctionScoreFunction boost = new BoostFactorFunction<ElasticsearchProject>(2);
			boost.Weight = 1;
			boost.Filter = new TermFilter {Field = Property.Path<ElasticsearchProject>(p => p.Name), Value = "termValue"};
			QueryContainer q = new FunctionScoreQuery()
			{
				Weight = 4,
				Functions = new[] {boost}

			};
			var json = TestElasticClient.Serialize(q);
			var expected = @"{
                            function_score: {
                              functions : [
                                {
                                    boost_factor: 2.0,
                                    filter:{
                                        term : {
                                            ""name"":""termValue""
                                        }
                                    },
                                    weight: 1.0
                                }
                              ],
                              weight: 4.0
                            }
                        }";

			Assert.True(json.JsonEquals(expected), json);
		}