public void Export_With_SearchParams_ReturnsValidJson() { var query = new PhraseQuery("foo").Field("bar"); var searchParams = new SearchParams(); var result = query.Export(searchParams).ToString(Formatting.None); var expected = JsonConvert.SerializeObject(new { ctl = new { timeout = 75000 }, query = new { boost = 0.0, field = "bar", terms = new[] { "foo" } } }, Formatting.None); Assert.AreEqual(expected, result); }
public void Sort_Adds_FieldNames_To_Output_Json() { var fields = new List<string> {"name", "-age"}; var searchParams = new SearchParams(); searchParams.Sort(fields.ToArray()); var result = searchParams.ToJson().ToString(Formatting.None); var expected = JsonConvert.SerializeObject(new { ctl = new { timeout = 75000 }, sort = fields }, Formatting.None); Assert.AreEqual(expected, result); }
public void Export_With_SearchParams_ReturnsValidJson() { var query = new DisjunctionQuery( new TermQuery("hotel").Field("type") ); var searchParams = new SearchParams(); var result = query.Export(searchParams).ToString(Formatting.None); var expected = JsonConvert.SerializeObject(new { ctl = new { timeout = 75000 }, query = new { boost = 0.0, min = 1, disjuncts = new[] { new { query = new { term = "hotel", boost = 0.0, field = "type", prefix_length = 0, fuzziness = 0 } } } } }, Formatting.None); Assert.AreEqual(expected, result); }
public SearchQuery() { SearchParams = new SearchParams(); }
/// <summary> /// List of fields values that should be returned in the result assuming that they were indexed. /// </summary> /// <param name="fields">The indexed fields to return.</param> /// <returns></returns> public SearchQuery Fields(params string[] fields) { SearchParams.Fields(fields); return(this); }
/// <summary> /// Allows setting of additional highlighting on the result set of matching terms. /// </summary> /// <param name="highLightStyle">The <see cref="HighLightStyle" /> to use.</param> /// <param name="fields">The specific terms or fields to highlight.</param> /// <returns></returns> public SearchQuery Highlighting(HighLightStyle highLightStyle, params string[] fields) { SearchParams.Highlighting(highLightStyle, fields); return(this); }
/// <summary> /// Allows setting of additional highlighting on the result set of matching terms. /// </summary> /// <param name="highLightStyle">The <see cref="HighLightStyle" /> to use.</param> /// <returns></returns> public SearchQuery Highlighting(HighLightStyle highLightStyle) { SearchParams.Highlighting(highLightStyle); return(this); }
public SearchQuery() { SearchParams = new SearchParams(); }
/// <summary> /// If true, the response will include additional search score explanations. /// </summary> /// <param name="explain"></param> /// <returns></returns> public SearchQuery Explain(bool explain) { SearchParams.Explain(explain); return(this); }