public virtual async Task <SearchQuery> Save([FromBody] SearchQuery query)
        {
            query.CheckValid();
            query.DbName = SearchQueryHelper.GetHash(query.FriendlyName);
            query.SetProject(GetTeam());
            query.RegisteredBy             = GetEmail();
            query.RegisteredByFriendlyName = GetFriendlyName();

            var manager = query.SearchIndex == IndexTypeName.Business ? _businessFilterManager : _personFilterManager;

            manager.Init(query.Filters);
            query.SelectedFilters = manager.GetSelectedFilters().ToList();
            var filters = query.Filters;

            query.Filters = null;
            if (!query.SelectedFilters.Any() && query.SearchTerm.IsEmpty())
            {
                throw new ArgumentException("No selected filters was found");
            }

            var result = await _queryDb.Post(query);

            query.Filters = filters;

            return(query);
        }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // Get search terms
            string searchtext = QueryHelper.GetString(searchUrlParameter, String.Empty);

            // Use try/catch block. Search text can be un-parsered for query parser
            try
            {
                // Get search clauses -> searched words
                SearchQueryClauses clauses = SearchQueryHelper.GetQueryClauses(searchtext, "_content");
                if (clauses != null)
                {
                    // Get collection of highlights
                    clauses.GetQuery(false, true);
                    List <string> searchTerms = clauses.HighlightedWords;

                    string currentCulture = String.IsNullOrEmpty(Language.Trim()) ? CMSContext.PreferredCultureCode : Language;

                    // Get suggestions
                    string dicFileName = currentCulture + ".dic";
                    string suggestion  = DidYouMean(dicFileName, searchtext, searchTerms);

                    // Show only if there is something to suggest
                    if (suggestion != String.Empty)
                    {
                        string queryText   = HTMLHelper.HTMLEncode(suggestion).Replace(startTag, String.Empty).Replace(endTag, String.Empty);
                        string visibleText = HTMLHelper.HTMLEncode(suggestion).Replace(startTag, StartTag).Replace(endTag, EndTag);

                        // Change value of search parameter
                        string url = URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, searchUrlParameter);
                        url = URLHelper.AddParameterToUrl(url, searchUrlParameter, queryText);

                        ltrText.Text          = Text;
                        lnkSearch.NavigateUrl = url;
                        lnkSearch.Text        = visibleText;
                    }
                    else
                    {
                        Visible = false;
                    }
                }
                else
                {
                    Visible = false;
                }
            }
            catch
            {
                Visible = false;
            }
        }
    }
Esempio n. 3
0
        public void TestMethod1()
        {
            IntPtr searchQueryHelper;
            var    hr = SearchQueryHelper.GetSearchQueryHelper(out searchQueryHelper);

            if (hr != 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            string sql;

            hr = SearchQueryHelper.GenerateSQLFromUserQuery(searchQueryHelper, "document", out sql);
            if (hr != 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            Assert.IsTrue(true);
        }