private void UpdateFilters(FilterQueryCollection filterQueries)
 {
     rptFilters.Visible = filterQueries.Count > 0;
     hidFilterQueries.Value = filterQueries.ToString();
     if (FilterChanged != null)
         FilterChanged(this, new FilterChangedEventArgs(filterQueries));
 }
 private void UpdateFilters(FilterQueryCollection filterQueries)
 {
     rptFilters.Visible     = filterQueries.Count > 0;
     hidFilterQueries.Value = filterQueries.ToString();
     if (FilterChanged != null)
     {
         FilterChanged(this, new FilterChangedEventArgs(filterQueries));
     }
 }
        protected void Query(string text, int start, string loggingId = null, FilterQueryCollection filterQueries = null)
        {
            if (text == null) text = txtSearch.Text.Trim();

            phSearchResults.Visible = true;
            lblQuery.Text = text;
            lblQueryNoResults.Text = text;

            if (filterQueries == null)
            {
                hidFilterQueries.Value = "";
                rptFilters.Visible = false;
            }
            else
            {
                hidFilterQueries.Value = filterQueries.ToString();
                rptFilters.Visible = filterQueries.Count > 0;
                rptFilters.DataSource = filterQueries;
                rptFilters.DataBind();
            }

            var search = new CrownPeak.SearchG2.PlainSearch(new Settings("www.crownpeak.com"));
            QueryOptions options = new QueryOptions()
            {
                Highlighting = true,
                Start = start,
                Rows = ROWS,
                SpellCheck = true,
                FacetFields = new[] { "url", "title" },
                FilterQueries = filterQueries,
                LoggingId = loggingId,
                // Language = "en" });
            };
            var resultSet = search.Execute(text, options);

            phSearchResultsNoResults.Visible = resultSet.Count == 0;
            phSearchResultsResults.Visible = !phSearchResultsNoResults.Visible;

            lblCount.Text = resultSet.TotalCount.ToString();
            lblFrom.Text = (start + 1).ToString();
            lblTo.Text = (start + resultSet.Count).ToString();

            phSuggestions.Visible = (resultSet.Suggestions.Count > 0);
            if (resultSet.Suggestions.Count > 0)
            {
                lbSuggestionCollation.Text = resultSet.Suggestions.Collation;
                lbSuggestionCollation.CommandArgument = resultSet.Suggestions.Collation;
            }

            if (resultSet.Facets != null && resultSet.Facets.Count > 0)
            {
                rptFacets.DataSource = resultSet.Facets;
                rptFacets.DataBind();
            }

            hidLoggingId.Value = "";
            var pages = Enumerable.Range(1, (int)Math.Ceiling((double)resultSet.TotalCount / ROWS));
            if (resultSet.CrownPeak != null && resultSet.CrownPeak.Logging != null)
            {
                hidLoggingId.Value = resultSet.CrownPeak.Logging.Id;
            }
            rptPager.DataSource = pages;
            rptPager.DataBind();
            rptPager.Visible = resultSet.TotalCount > ROWS;

            rptResults.DataSource = resultSet;
            rptResults.DataBind();
        }
        protected void Query(string text, int start, string loggingId = null, FilterQueryCollection filterQueries = null)
        {
            if (text == null)
            {
                text = txtSearch.Text.Trim();
            }

            phSearchResults.Visible = true;
            lblQuery.Text           = text;
            lblQueryNoResults.Text  = text;

            if (filterQueries == null)
            {
                hidFilterQueries.Value = "";
                rptFilters.Visible     = false;
            }
            else
            {
                hidFilterQueries.Value = filterQueries.ToString();
                rptFilters.Visible     = filterQueries.Count > 0;
                rptFilters.DataSource  = filterQueries;
                rptFilters.DataBind();
            }

            var          search  = new CrownPeak.SearchG2.PlainSearch(new Settings("www.crownpeak.com"));
            QueryOptions options = new QueryOptions()
            {
                Highlighting  = true,
                Start         = start,
                Rows          = ROWS,
                SpellCheck    = true,
                FacetFields   = new[] { "url", "title" },
                FilterQueries = filterQueries,
                LoggingId     = loggingId,
                // Language = "en" });
            };
            var resultSet = search.Execute(text, options);

            phSearchResultsNoResults.Visible = resultSet.Count == 0;
            phSearchResultsResults.Visible   = !phSearchResultsNoResults.Visible;

            lblCount.Text = resultSet.TotalCount.ToString();
            lblFrom.Text  = (start + 1).ToString();
            lblTo.Text    = (start + resultSet.Count).ToString();

            phSuggestions.Visible = (resultSet.Suggestions.Count > 0);
            if (resultSet.Suggestions.Count > 0)
            {
                lbSuggestionCollation.Text            = resultSet.Suggestions.Collation;
                lbSuggestionCollation.CommandArgument = resultSet.Suggestions.Collation;
            }

            if (resultSet.Facets != null && resultSet.Facets.Count > 0)
            {
                rptFacets.DataSource = resultSet.Facets;
                rptFacets.DataBind();
            }

            hidLoggingId.Value = "";
            var pages = Enumerable.Range(1, (int)Math.Ceiling((double)resultSet.TotalCount / ROWS));

            if (resultSet.CrownPeak != null && resultSet.CrownPeak.Logging != null)
            {
                hidLoggingId.Value = resultSet.CrownPeak.Logging.Id;
            }
            rptPager.DataSource = pages;
            rptPager.DataBind();
            rptPager.Visible = resultSet.TotalCount > ROWS;

            rptResults.DataSource = resultSet;
            rptResults.DataBind();
        }