UnifiedSearch with multiple sites

Vote:
 

I have a EPiServer solution with two sites and i use Find .NET API-version: 9.3.0.2674.

I want to get the search results from both sites but now i only get the results from the site im currenty browsing.

Both sites are indexed and i can see the page i want in the index.

If i use TypedSearch i get all the pages but when i use UnifiedSearchFor i only get one site pages.

var q = (ITypeSearch)TVSearchClient.Instance.UnifiedSearchFor(query, Language.Swedish);
var result = q.GetResult();
#123271
Jun 30, 2015 14:02
Vote:
 

If i try with and older version of Find (8.6.0.1055) i got results from both sites.

#123297
Jul 01, 2015 9:51
Vote:
 

Unfortunately Find 9+? has .FilterOnCurrentSite() per default, but what you can do is to create an initialization module which overrides the unifiedSearchRegistry where you could exclude whatever you want. I have some code here which you can use:

using System;
using EPiServer.Core;
using EPiServer.Find.Helpers;
using EPiServer.Find.UnifiedSearch;
using EPiServer.Logging.Compatibility;
using EPiServer.ServiceLocation;
using EPiServer.Web.Routing;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.Find;
using EPiServer.Find.Cms.Module;
using EPiServer.Find.Framework;
using EPiServer.Find.Cms;
using EPiServer.Globalization;


namespace EPiServer.Templates.Alloy.Business.Initialization
{
    [InitializableModule]
    [ModuleDependency(typeof(IndexingModule))]
    public class FindLanguageInitialization : IInitializableModule
    {
        public void Initialize(InitializationEngine context)
        {
            var cmsunifiedsearchsetup = new EPiServer.Find.Cms.CmsUnifiedSearchSetUp();
                        
            SearchClient.Instance.Conventions.UnifiedSearchRegistry
                .Add<PageData>()
                .PublicSearchFilter((c, ctx) => c.BuildFilter<IContentData>()                    
                    .FilterForVisitor(ctx.Language == null || ctx.Language == Language.None ? Languages.AllLanguagesSuffix : ctx.Language.FieldSuffix)
                    .ExcludeContainerPages()
                    .ExcludeContentFolders()
                    .FilterOnCurrentSite()) //this part you could comment away
                .CustomizeIndexProjection(cmsunifiedsearchsetup.CustomizeIndexProjectionForPageData)
                .CustomizeProjection(cmsunifiedsearchsetup.CustomizeProjectionForPageData);

            SearchClient.Instance.Conventions.UnifiedSearchRegistry
                .Add<MediaData>()
                .PublicSearchFilter((c, ctx) => c.BuildFilter<IContentData>()            
                    .FilterForVisitor(ctx.Language == null || ctx.Language == Language.None ? Languages.AllLanguagesSuffix : ctx.Language.FieldSuffix)
                    .ExcludeContentFolders()
                    .FilterOnCurrentSite()) //this part you could comment away
                .CustomizeIndexProjection(cmsunifiedsearchsetup.CustomizeIndexProjectionForMediaData)
                .CustomizeProjection(cmsunifiedsearchsetup.CustomizeProjectionForMediaData);
        
            //Add initialization logic, this method is called once after CMS has been initialized
        }

        public void Preload(string[] parameters) { }

        public void Uninitialize(InitializationEngine context)
        {
            //Add uninitialization logic
        }
    }
}
#123593
Jul 09, 2015 12:15
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.