public Export ( ) : Newtonsoft.Json.Linq.JObject | ||
return | Newtonsoft.Json.Linq.JObject |
public override JObject Export()
{
var json = base.Export();
json.Add(new JProperty("match", _match));
json.Add(new JProperty("prefix_length", _prefixLength));
json.Add(new JProperty("fuzziness", _fuzziness));
if (!string.IsNullOrEmpty(_field))
{
json.Add(new JProperty("field", _field));
}
if (!string.IsNullOrEmpty(_analyzer))
{
json.Add(new JProperty("analyzer", _analyzer));
}
return json;
}
}
public void Export_Omits_Field_If_Not_Present() { var query = new MatchQuery("somematchquery"); var expected = JsonConvert.SerializeObject(new { match = "somematchquery", prefix_length = 0, fuzziness = 0 }, Formatting.None); Assert.AreEqual(expected, query.Export().ToString(Formatting.None)); }