Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 1.14 KB

search-provider.md

File metadata and controls

35 lines (31 loc) · 1.14 KB

Search Provider

[SearchProvider]
public class InternalPageSearchProvider : PageSearchProvider
{
    public InternalPageSearchProvider(LocalizationService localizationService,
            SiteDefinitionResolver siteDefinitionResolver,
            PageTypeRepository contentTypeRepository,
            IContentRepository contentRepository,
            ILanguageBranchRepository languageBranchRepository,
            SearchHandler searchHandler,
            ContentSearchHandler contentSearchHandler,
            SearchIndexConfig searchIndexConfig)
            : base(localizationService, siteDefinitionResolver, contentTypeRepository, contentRepository, languageBranchRepository, searchHandler, contentSearchHandler, searchIndexConfig)
    {
    }

    public override IEnumerable<SearchResult> Search(Query query)
    {
        query.MaxResults = 20;
        if (query.SearchQuery.Contains("country:"))
        {
            query.SearchQuery = query.SearchQuery.Replace("country:", string.Empty);
                query.SearchRoots = new[] { "33" };
        }

        return base.Search(query);
    }
}

⬅️ BACK