public static SearchResults GetPortalSearchWikiResults(string searchTerm, LoginUser loginUser, int parentOrgID)
        {
            Options options = new Options();

            options.TextFlags = TextFlags.dtsoTfRecognizeDates;
            using (SearchJob job = new SearchJob())
            {
                StringBuilder conditions = new StringBuilder();
                conditions.Append(" ((PortalView::True) AND (IsDeleted::false))");

                job.Request           = searchTerm;
                job.FieldWeights      = "ArticleName: 1000";
                job.BooleanConditions = conditions.ToString();
                job.TimeoutSeconds    = 30;
                job.SearchFlags       = SearchFlags.dtsSearchDelayDocInfo;

                int num = 0;
                if (!int.TryParse(searchTerm, out num))
                {
                    job.SearchFlags = job.SearchFlags |
                                      SearchFlags.dtsSearchPositionalScoring |
                                      SearchFlags.dtsSearchAutoTermWeight;
                }

                if (searchTerm.ToLower().IndexOf(" and ") < 0 && searchTerm.ToLower().IndexOf(" or ") < 0)
                {
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchTypeAllWords;
                }
                job.IndexesToSearch.Add(DataUtils.GetPortalWikiIndexPath(loginUser, parentOrgID));
                job.Execute();

                return(job.Results);
            }
        }
Exemple #2
0
        public List <ResultModel> Search(string txt, string option)
        {
            List <ResultModel> lst = new List <ResultModel>();

            SearchJob sj1 = new SearchJob();

            sj1.BooleanConditions = txt;
            string[] ddlist;
            ddlist = Directory.GetDirectories(@"C:\Users\meharr\AppData\Local\dtSearch");
            sj1.IndexesToSearch.AddRange(ddlist);
            sj1.MaxFilesToRetrieve = 100;
            if (option == "stemming")
            {
                sj1.SearchFlags = SearchFlags.dtsSearchStemming;
            }
            else if (option == "phonic")
            {
                sj1.SearchFlags = SearchFlags.dtsSearchPhonic;
            }
            else if (option == "fuzzy")
            {
                sj1.Fuzziness   = 5;
                sj1.SearchFlags = SearchFlags.dtsSearchFuzzy;
            }
            sj1.Execute();

            SearchResults result = sj1.Results;

            for (int i = 0; i < result.Count; i++)
            {
                var tile = HighlightResult(i, result);
                int len  = tile.Length;
                int ind  = tile.IndexOf("Filename");
                tile = tile.Remove(ind, Math.Abs(ind - len));
                result.GetNthDoc(i);
                SearchResultsItem item = result.CurrentItem;

                ResultModel mod = new ResultModel();
                mod.DisplayName = item.DisplayName;
                mod.FileName    = item.Filename;
                mod.Title       = tile;
                mod.HitCount    = item.HitCount;
                lst.Add(mod);
            }
            return(lst);
        }
        private void DoSearch(string searchRequest, QueryResult result)
        {
            Debug.Assert(result.HitCount == 0);

            SearchJob search = BuildSearchJob(result.SourceTable);

            search.Request = searchRequest;

            _logger.DTSearchStarted(result.SourceTable, search.Request);
            {
                search.Execute();
                result.HitCount = search.Results.Count;

                ProcessResults(result, search.Results);
            }
            _logger.DTSearchStopped(result.SourceTable, result.ResultTable, result.HitCount);
        }
        public static SearchResults GetSearchNotesResults(string searchTerm, LoginUser loginUser)
        {
            Options options = new Options();

            options.TextFlags = TextFlags.dtsoTfRecognizeDates;
            using (SearchJob job = new SearchJob())
            {
                searchTerm       = searchTerm.Trim();
                job.Request      = searchTerm;
                job.FieldWeights = "Title: 1000";

                //StringBuilder conditions = new StringBuilder();
                //job.BooleanConditions = conditions.ToString();


                //job.MaxFilesToRetrieve = 1000;
                //job.AutoStopLimit = 1000000;
                job.TimeoutSeconds = 30;
                job.SearchFlags    =
                    //SearchFlags.dtsSearchSelectMostRecent |
                    SearchFlags.dtsSearchDelayDocInfo;

                int num = 0;
                if (!int.TryParse(searchTerm, out num))
                {
                    //job.Fuzziness = 1;
                    job.SearchFlags = job.SearchFlags |
                                      //SearchFlags.dtsSearchFuzzy |
                                      //SearchFlags.dtsSearchStemming |
                                      SearchFlags.dtsSearchPositionalScoring |
                                      SearchFlags.dtsSearchAutoTermWeight;
                }

                if (searchTerm.ToLower().IndexOf(" and ") < 0 && searchTerm.ToLower().IndexOf(" or ") < 0)
                {
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchTypeAllWords;
                }
                job.IndexesToSearch.Add(DataUtils.GetNotesIndexPath(loginUser));
                job.Execute();

                return(job.Results);
            }
        }
Exemple #5
0
        public RadComboBoxItemData[] GetKBTicketByDescription(RadComboBoxContext context)
        {
            Options options = new Options();

            options.TextFlags = TextFlags.dtsoTfRecognizeDates;

            using (SearchJob job = new SearchJob())
            {
                string searchTerm = context["FilterString"].ToString().Trim();
                job.Request            = searchTerm;
                job.FieldWeights       = "TicketNumber: 5000, Name: 1000";
                job.BooleanConditions  = "(OrganizationID::" + TSAuthentication.OrganizationID.ToString() + ") AND (IsKnowledgeBase::True)";
                job.MaxFilesToRetrieve = 25;
                job.AutoStopLimit      = 100000;
                job.TimeoutSeconds     = 10;
                job.SearchFlags        =
                    SearchFlags.dtsSearchSelectMostRecent |
                    SearchFlags.dtsSearchStemming |
                    SearchFlags.dtsSearchDelayDocInfo;

                int num = 0;
                if (!int.TryParse(searchTerm, out num))
                {
                    job.Fuzziness   = 1;
                    job.Request     = job.Request + "*";
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchFuzzy;
                }

                if (searchTerm.ToLower().IndexOf(" and ") < 0 && searchTerm.ToLower().IndexOf(" or ") < 0)
                {
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchTypeAllWords;
                }
                job.IndexesToSearch.Add(DataUtils.GetTicketIndexPath(TSAuthentication.GetLoginUser()));
                job.Execute();
                SearchResults results = job.Results;


                IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context;
                List <RadComboBoxItemData>   list = new List <RadComboBoxItemData>();
                try
                {
                    for (int i = 0; i < results.Count; i++)
                    {
                        results.GetNthDoc(i);
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        itemData.Text  = results.CurrentItem.DisplayName;
                        itemData.Value = results.CurrentItem.Filename + "," + results.CurrentItem.UserFields["TicketNumber"].ToString();
                        list.Add(itemData);
                    }
                }
                catch (Exception)
                {
                }
                if (list.Count < 1)
                {
                    RadComboBoxItemData noData = new RadComboBoxItemData();
                    noData.Text  = "[No tickets to display.]";
                    noData.Value = "-1";
                    list.Add(noData);
                }

                return(list.ToArray());
            }
        }