Exemple #1
0
        /// <summary>
        /// 专题全局搜索
        /// </summary>
        public ActionResult _GlobalSearch(TopicFullTextQuery query, int topNumber)
        {
            query.PageSize  = topNumber;//每页记录数
            query.PageIndex = 1;

            //调用搜索器进行搜索
            TopicSearcher groupSearcher        = (TopicSearcher)SearcherFactory.GetSearcher(TopicSearcher.CODE);
            PagingDataSet <TopicEntity> groups = groupSearcher.Search(query);

            return(PartialView(groups));
        }
Exemple #2
0
        /// <summary>
        /// 专题快捷搜索
        /// </summary>
        public ActionResult _QuickSearch(TopicFullTextQuery query, int topNumber)
        {
            query.PageSize  = topNumber;//每页记录数
            query.PageIndex = 1;
            query.Range     = TopicSearchRange.GROUPNAME;
            query.Keyword   = Server.UrlDecode(query.Keyword);
            //调用搜索器进行搜索
            TopicSearcher TopicSearcher        = (TopicSearcher)SearcherFactory.GetSearcher(TopicSearcher.CODE);
            PagingDataSet <TopicEntity> groups = TopicSearcher.Search(query);

            return(PartialView(groups));
        }
Exemple #3
0
        /// <summary>
        /// 专题搜索
        /// </summary>
        public ActionResult Search(TopicFullTextQuery query)
        {
            query.Keyword  = WebUtility.UrlDecode(query.Keyword);
            query.PageSize = 20;//每页记录数

            //调用搜索器进行搜索
            TopicSearcher groupSearcher        = (TopicSearcher)SearcherFactory.GetSearcher(TopicSearcher.CODE);
            PagingDataSet <TopicEntity> groups = groupSearcher.Search(query);

            //添加到用户搜索历史
            IUser CurrentUser = UserContext.CurrentUser;

            if (CurrentUser != null)
            {
                if (!string.IsNullOrWhiteSpace(query.Keyword))
                {
                    SearchHistoryService searchHistoryService = new SearchHistoryService();
                    searchHistoryService.SearchTerm(CurrentUser.UserId, TopicSearcher.CODE, query.Keyword);
                }
            }

            //添加到热词
            if (!string.IsNullOrWhiteSpace(query.Keyword))
            {
                SearchedTermService searchedTermService = new SearchedTermService();
                searchedTermService.SearchTerm(TopicSearcher.CODE, query.Keyword);
            }

            //设置页面Meta
            if (string.IsNullOrWhiteSpace(query.Keyword))
            {
                pageResourceManager.InsertTitlePart("专题搜索");//设置页面Title
            }
            else
            {
                pageResourceManager.InsertTitlePart('“' + query.Keyword + '”' + "的相关专题");//设置页面Title
            }

            return(View(groups));
        }
Exemple #4
0
        public ActionResult _InterestTopic()
        {
            TagService tagService  = new TagService(TenantTypeIds.Instance().User());
            IUser      currentUser = UserContext.CurrentUser;

            if (currentUser != null)
            {
                TopicFullTextQuery query = new TopicFullTextQuery();
                query.PageSize  = 20;
                query.PageIndex = 1;
                query.Range     = TopicSearchRange.TAG;
                query.Tags      = tagService.GetTopTagsOfItem(currentUser.UserId, 100).Select(n => n.TagName);
                query.TopicIds  = topicService.GetMyJoinedTopics(currentUser.UserId, 100, 1).Select(n => n.TopicId.ToString());
                //调用搜索器进行搜索
                TopicSearcher             TopicSearcher = (TopicSearcher)SearcherFactory.GetSearcher(TopicSearcher.CODE);
                IEnumerable <TopicEntity> groupsTag     = null;
                if (TopicSearcher.Search(query, true).Count == 0)
                {
                    return(View());
                }
                else
                {
                    groupsTag = TopicSearcher.Search(query, true).AsEnumerable <TopicEntity>();
                }
                if (groupsTag.Count() < 20)
                {
                    IEnumerable <TopicEntity> groupsFollow = topicService.FollowedUserAlsoJoinedTopics(currentUser.UserId, 20 - groupsTag.Count());
                    return(View(groupsTag.Union(groupsFollow)));
                }
                else
                {
                    return(View(groupsTag));
                }
            }
            else
            {
                return(View());
            }
        }