Beispiel #1
0
        public IEnumerable <MentionUserModel> SearchMention(string query)
        {
            var searchResult = _elasticIndex.Search(new SearchTextQuery
            {
                Text = query,
                Take = 5,
                SearchableTypeIds = UintraSearchableTypeEnum.Member.ToInt().ToListOfOne(),
                OnlyPinned        = false,
                ApplyHighlights   = false
            });

            var results = searchResult.Documents.Select(d =>
            {
                var searchableUser = (SearchableMember)d;
                var user           = new MentionUserModel()
                {
                    Id    = Guid.Parse(searchableUser.Id.ToString()),
                    Value = searchableUser.FullName
                };
                user.Url = _profileLinkProvider.GetProfileLink(user.Id);
                return(user);
            });

            return(results);
        }
        public virtual PartialViewResult Search(SearchFilterModel model)
        {
            var searchableTypeIds = model.Types.Count > 0 ? model.Types : GetSearchableTypes().Select(t => t.ToInt());

            var searchResult = _elasticIndex.Search(new SearchTextQuery
            {
                Text = model.Query,
                Take = ResultsPerPage * model.Page,
                SearchableTypeIds = searchableTypeIds,
                OnlyPinned        = model.OnlyPinned,
                ApplyHighlights   = true
            });

            var resultModel = GetSearchResultsOverviewModel(searchResult);

            resultModel.Query = model.Query;

            return(PartialView(SearchResultViewPath, resultModel));
        }
Beispiel #3
0
        public void Map(SearchPageModel node, SearchPageViewModel viewModel)
        {
            var query        = System.Web.HttpUtility.ParseQueryString(_requestContext.NodeRequestParams.NodeUrl.Query).TryGetQueryValue <string>("query");
            var searchResult = _elasticIndex.Search(new SearchTextQuery
            {
                Text = query,
                Take = ResultsPerPage * 1,
                SearchableTypeIds = GetSearchableTypes().Select(t => t.ToInt()),
                OnlyPinned        = false,
                ApplyHighlights   = true
            });

            var resultModel = ExtendSearchPage(searchResult, viewModel);

            resultModel.Query = query;
        }
Beispiel #4
0
        protected override (IEnumerable <Guid> searchResult, long totalHits) GetActiveUserIds(ActiveUserSearchQuery query)
        {
            var searchQuery = new SearchTextQuery
            {
                Text              = query.Text,
                Skip              = query.Skip,
                Take              = query.Take,
                OrderingString    = query.OrderingString,
                SearchableTypeIds = ((int)UintraSearchableTypeEnum.User).ToEnumerable(),
                GroupId           = query.GroupId
            };

            var searchResult = _elasticIndex.Search(searchQuery);
            var result       = searchResult.Documents.Select(r => Guid.Parse(r.Id.ToString()));

            return(result, searchResult.TotalHits);
        }
Beispiel #5
0
        protected override IEnumerable <Guid> GetActiveUserIds(int skip, int take, string query, out long totalHits, string orderBy, int direction)
        {
            var searchQuery = new SearchTextQuery
            {
                Text              = query,
                Skip              = skip,
                Take              = take,
                OrderingString    = orderBy,
                OrderingDirection = direction,
                SearchableTypeIds = ((int)UintraSearchableTypeEnum.User).ToEnumerable()
            };
            var searchResult = _elasticIndex.Search(searchQuery);

            totalHits = searchResult.TotalHits;

            return(searchResult.Documents.Select(r => r.Id.ToString().Pipe(Guid.Parse)));
        }
Beispiel #6
0
        public override PartialViewResult Search(SearchFilterModel model)
        {
            var searchableTypeIds = model.Types.Count > 0 ? model.Types : GetSearchableTypes().Select(t => t.ToInt());

            var searchResult = _elasticIndex.Search(new SearchTextQuery
            {
                Text              = model.Query,
                OnlyPinned        = model.OnlyPinned,
                Take              = ResultsPerPage * model.Page,
                SearchableTypeIds = searchableTypeIds,
                ApplyHighlights   = true
            });

            var resultModel  = GetUintraSearchResultsOverviewModel(searchResult);
            var decodedQuery = Encoding.UTF8.GetString(model.Query.Select(c => (byte)c).ToArray());

            resultModel.Query = decodedQuery;

            return(PartialView(SearchResultViewPath, resultModel));
        }
Beispiel #7
0
        public List <string> SearchQuery(QueryContainer query)
        {
            var response = (ISearchResponse <Document>)index.Search(query);

            return(response.Documents.Select(s => s.Content).ToList());
        }