コード例 #1
0
 public static SuggestionQuery Select(this SuggestionQuery query, string selectField)
 {
     if (String.IsNullOrEmpty(query.Select))
     {
         query.Select = selectField;
     }
     else
     {
         query.Select += "," + selectField;
     }
     return(query);
 }
コード例 #2
0
 public static SuggestionQuery OrderBy(this SuggestionQuery query, string orderByField)
 {
     if (String.IsNullOrEmpty(query.OrderBy))
     {
         query.OrderBy = orderByField;
     }
     else
     {
         query.OrderBy += "," + orderByField;
     }
     return(query);
 }
コード例 #3
0
 public static SuggestionQuery SearchField(this SuggestionQuery query, string searchField)
 {
     if (String.IsNullOrEmpty(query.SearchFields))
     {
         query.SearchFields = searchField;
     }
     else
     {
         query.SearchFields += "," + searchField;
     }
     return(query);
 }
コード例 #4
0
        /// <summary>
        /// Get suggestions from an index.
        /// </summary>
        /// <param name="indexName"></param>
        /// <param name="query"></param>
        /// <param name="cancellationToken">cancel token</param>
        /// <returns></returns>
        public Task<IApiResponse<SuggestionResult>> SuggestAsync(string indexName, SuggestionQuery query, CancellationToken cancellationToken)
        {
            var request = new ApiRequest("indexes/{0}/docs/suggest", HttpMethod.Get);
            if (!String.IsNullOrEmpty(query.Search))
                request.AddQueryParameter("search", query.Search);

            request.AddQueryParameter("fuzzy", query.Fuzzy ? Boolean.TrueString : Boolean.FalseString);

            if (!String.IsNullOrEmpty(query.SearchFields))
                request.AddQueryParameter("searchFields", query.SearchFields);

            if (query.Top > 0)
                request.AddQueryParameter("$top", query.Top.ToString(CultureInfo.InvariantCulture));

            if (!String.IsNullOrEmpty(query.OrderBy))
                request.AddQueryParameter("$orderby", query.OrderBy);
            if (!String.IsNullOrEmpty(query.Select))
                request.AddQueryParameter("$select", query.Select);

            if (!String.IsNullOrEmpty(query.SuggesterName))
                request.AddQueryParameter("suggesterName", query.SuggesterName);

            if (!String.IsNullOrEmpty(query.Filter))
                request.AddQueryParameter("$filter", query.Filter);

            return _connection.Execute<SuggestionResult>(request.WithUriParameter(indexName), cancellationToken);
        }
コード例 #5
0
 /// <summary>
 /// Get suggestions from an index.
 /// </summary>
 /// <param name="indexName"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 public Task<IApiResponse<SuggestionResult>> SuggestAsync(string indexName, SuggestionQuery query)
 {
     return SuggestAsync(indexName, query, default(CancellationToken));
 }
コード例 #6
0
 public static SuggestionQuery Fuzzy(this SuggestionQuery query, bool fuzzy)
 {
     query.Fuzzy = fuzzy;
     return(query);
 }
コード例 #7
0
 public static SuggestionQuery Filter(this SuggestionQuery query, string filter)
 {
     query.Filter = filter;
     return(query);
 }
コード例 #8
0
 public static SuggestionQuery Top(this SuggestionQuery query, long top)
 {
     query.Top = top;
     return(query);
 }
コード例 #9
0
 public static SuggestionQuery SuggesterName(this SuggestionQuery query, string suggesterName)
 {
     query.SuggesterName = suggesterName;
     return(query);
 }