Inheritance: Sdl.Web.Common.Models.EntityModel
 protected override NameValueCollection SetupParameters(SearchQuery searchQuery, Localization localization)
 {
     NameValueCollection parameters = base.SetupParameters(searchQuery, localization);
     // We use the highlighting feature to autogenerate a Summary if no Summary is present in the search index.
     parameters["hl"] = "true";
     return parameters;
 }
        protected virtual NameValueCollection SetupParameters(SearchQuery searchQuery, Localization localization)
        {
            NameValueCollection result = new NameValueCollection(searchQuery.QueryStringParameters);
            result["fq"] = "publicationid:" + localization.LocalizationId;
            result["q"] = searchQuery.QueryText;
            result["start"] = searchQuery.Start.ToString(CultureInfo.InvariantCulture);
            result["rows"] = searchQuery.PageSize.ToString(CultureInfo.InvariantCulture);

            return result;
        }
 protected override NameValueCollection SetupParameters(SearchQuery searchQuery, Localization localization)
 {
     NameValueCollection result = base.SetupParameters(searchQuery, localization);
     if (!result.AllKeys.Contains("q.options"))
     {
         // By default, limit the search to body, summary and title fields.
         result["q.options"] = "{ fields: ['body', 'summary', 'title'] }";
     }
     // We use the highlighting feature to autogenerate a Summary if no Summary is present in the search index.
     result["highlight"] = "{ body: { format: \"text\", max_phrases: 2 } }";
     return result;
 }
        public void ExecuteQuery(SearchQuery searchQuery, Type resultType, Localization localization)
        {
            using (new Tracer(searchQuery, resultType, localization))
            {
                string searchIndexUrl = GetSearchIndexUrl(localization);
                NameValueCollection parameters = SetupParameters(searchQuery, localization);
                SearchResults results = ExecuteQuery(searchIndexUrl, parameters);
                if (results.HasError)
                {
                    Log.Error("Error executing Search Query on URL '{0}': {1}", results.QueryUrl ?? searchIndexUrl, results.ErrorDetail);
                }
                Log.Debug("Search Query '{0}' returned {1} results.", results.QueryText ?? results.QueryUrl, results.Total);

                searchQuery.Total = results.Total;
                searchQuery.HasMore = searchQuery.Start + searchQuery.PageSize <= results.Total;
                searchQuery.CurrentPage = ((searchQuery.Start - 1) / searchQuery.PageSize) + 1;

                foreach (SearchResult result in results.Items)
                {
                    searchQuery.Results.Add(MapResult(result, resultType, searchQuery.SearchItemView));
                }
            }
        }