Represents a number of query options that can be applied to a FTS query request.
Inheritance: ISearchParams
        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);
        }
Ejemplo n.º 4
0
 public SearchQuery()
 {
     SearchParams = new SearchParams();
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 /// <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);
 }
Ejemplo n.º 7
0
 /// <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);
 }
Ejemplo n.º 8
0
 public SearchQuery()
 {
     SearchParams = new SearchParams();
 }
Ejemplo n.º 9
0
 /// <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);
 }