Ejemplo n.º 1
0
 public void FAIL_Create()
 {
     try
     {
         Rescore rescore = new Rescore(null);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("rescoreQueries", ex.ParamName);
     }
 }
Ejemplo n.º 2
0
 public void PASS_Create()
 {
     Rescore rescore = new Rescore(new List<RescoreQuery>()
         {
             new RescoreQuery(new TermQuery("field", "value"))
         });
     Assert.IsNotNull(rescore);
     Assert.AreEqual(1, rescore.RescoreQueries.Count());
     Assert.IsTrue(rescore.RescoreQueries.First().Query is TermQuery);
     Assert.AreEqual("field", (rescore.RescoreQueries.First().Query as TermQuery).Field);
     Assert.AreEqual("value", (rescore.RescoreQueries.First().Query as TermQuery).Value);
 }
Ejemplo n.º 3
0
        public void PASS_Serialize()
        {
            Rescore rescore = new Rescore(new List<RescoreQuery>()
                {
                    new RescoreQuery(new TermQuery("field", "value"))
                    {
                        QueryWeight = 0.7,
                        RescoreQueryWeight = 1.3,
                        ScoreMode = ScoreModeEnum.Maximum,
                        WindowSize = 10
                    }
                });

            string json = JsonConvert.SerializeObject(rescore);
            Assert.IsNotNull(json);
            string expectedJson = "{\"window_size\":10,\"query\":{\"score_mode\":\"max\",\"rescore_query\":{\"term\":{\"field\":\"value\"}},\"query_weight\":0.7,\"rescore_query_weight\":1.3}}";
            Assert.AreEqual(expectedJson, json);
        }