Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Raja 1 post 71 karma points
    Feb 25, 2021 @ 08:57
    Raja
    0

    Search Single content not searching all the contents

    Hi Team,

    Currently in the url it is searching all the contents with the search term cancel.

    https://www.businessdirect.bt.com/help/search/?SearchTerm=cancel

    Currently in the url it is searching only one contents with the search term cancel

    https://shop.bt.com/help/search/?SearchTerm=cancel

    Coding:

    if (string.IsNullOrWhiteSpace(searchTerm)) { return new List

            var storegroupContentId = _storegroupService.GetContentIdForStoregroup(_store.StoreGroupId).ToString();
            var searcher = _examineManagerProxy.GetSearchProvider(ExamineConstants.SearchProviderName);
    
            var searchCriteria = searcher.CreateSearchCriteria();
            IBooleanOperation filter = null;
    
            foreach (var word in searchTerm.Split(' '))
            {
                if (filter == null)
                {
                    filter = searchCriteria.GroupedOr(new List<string> { DocTypeProperties.BodyText, ExamineConstants.NodeNameFieldName, DocTypeProperties.SummaryDescription, DocTypeProperties.MetaDescription, DocTypeProperties.Title, DocTypeProperties.HtmlPageTitle, DocTypeProperties.MetaKeywords, ExamineConstants.ComponentsContentFieldName }, new[] { word });
                }
                else
                {
                    filter = filter.Or().GroupedOr(new List<string> { DocTypeProperties.BodyText, ExamineConstants.NodeNameFieldName, DocTypeProperties.SummaryDescription, DocTypeProperties.MetaDescription, DocTypeProperties.Title, ExamineConstants.ComponentsContentFieldName }, new[] { word });
                }
            }
    
    
            filter = filter.And().Field(ExamineConstants.PathSpaceDelimitedFieldName, storegroupContentId);
            filter = filter.And().Field(DocTypeProperties.HideFromSearch, "0");
    
    
            if (contentType == SearchContentType.All)
            {
                filter = filter.And().GroupedOr(new List<string> { ExamineConstants.NodeTypeAliasFieldName },
                                                new List<string> { SearchContentType.HelpArticle.ToString(), 
                                                                   SearchContentType.InternalArticle.ToString(), 
                                                                   SearchContentType.LearnMoreArticle.ToString(), 
                                                                   SearchContentType.OtherArticle.ToString(), 
                                                                   SearchContentType.PromotionsAndPressReleasesArticle.ToString() 
                                                                 }.ToArray());
            }
            else
            {
                filter = filter
                    .And()
                    .Field(ExamineConstants.NodeTypeAliasFieldName, contentType.ToString());
            }
    
            var results = searcher.Search(filter.Compile());
    
    
            return results.Select(MapSearchResult);
    

    Could you please help me on this issue.

    Thanks, Raja

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Mar 23, 2021 @ 23:12
    Alex Skrypnyk
    0

    Hi Raja

    What Umbraco version are you using? version 6?

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft