public Export ( ) : Newtonsoft.Json.Linq.JObject | ||
return | Newtonsoft.Json.Linq.JObject |
public void Throws_InvalidOperationException_When_No_Sub_Queries() { var query = new BooleanQuery(); Assert.Throws<InvalidOperationException>(() => query.Export()); Assert.Throws<InvalidOperationException>(() => query.Export(new SearchParams())); }
public void Export_ReturnsValidJson() { var query = new BooleanQuery(); query.Must(new TermQuery("hotel").Field("type")); var result = query.Export().ToString(Formatting.None); var expected = JsonConvert.SerializeObject(new { query = new { boost = 0.0, must = new[] { new { query = new { term = "hotel", boost = 0.0, field = "type", prefix_length = 0, fuzziness = 0 } } }, must_not = new dynamic[] {}, should = new dynamic[] {} } }, Formatting.None); Assert.AreEqual(expected, result); }
public void Export_Returns_Valid_Json_For_MustNot() { var query = new BooleanQuery(); query.MustNot(new TermQuery("hotel").Field("type")); var result = query.Export().ToString(Formatting.None); var expected = JsonConvert.SerializeObject(new { must_not = new { min = 1, disjuncts = new dynamic[] { new { term = "hotel", prefix_length = 0, fuzziness = 0, field = "type" } } } }, Formatting.None); Assert.AreEqual(expected, result); }
public void Can_Execute_Query_With_Only_One_Type_Of_Sub_Query() { var query = new BooleanQuery(); query.Must(new TermQuery("hotel").Field("type")); var result = query.Export(); Assert.IsNotNull(result); }