Try our conversational search powered by Generative AI!

UnifiedSearch won't return results from more than 1 targetted sites in multisite environment


We have a requirement in our environment when using EPiServer Find where I need to search and return the results from only specific sites in our multisite environment, depending on the site where the search is being executed.

For example, in our environment we have a single site that acts as the parent site and all other sites are considered child sites of that parent:

Site1 - Parent Site
Site2 - Child Site
Site3 - Child Site
Site4 - Child Site
..... etc

Given the above scenario, if someone was on Site3 and was performing a search then the results of that search from the contents on Site3 + the results from Site1 should only be returned. Likewise if someone was on Site2 then the contents on that site should be returned + the results from Site1 should be returned, etc, etc..

The problem i am running into is that in a UnifiedSearch I cannot target the 2 sites when on one of the child sites, meaning if i do the search on Site3 then it's only giving me the contents from Site3 and not from Site1 even when i'm adding a filter to include Site1 in the search results.

Below is the code i'm using:

ITypeSearch<ISearchContent> unifiedSearch = SearchClient.Instance.UnifiedSearchFor(q);
var filter = SearchClient.Instance.BuildFilter<PageData>();
filter = filter1.And(x => x.SiteId().Match("Site1_ID"));
filter = filter1.And(x => x.SiteId().Match("CurrentSite_ID"));
viewModel.SearchResults = unifiedSearch.ApplyBestBets().GetResult();

I'm not sure what i'm doing wrong, but i can't seem to return the results from anyting other than the current site i'm on, which defeats the purpose for what we need to accomplish.

Does anyone know anything about this? Or what i might be missing?

Nov 17, 2020 14:01

Still looking into a solution for this, i'm not sure if anyone else has had this problem or not and can shed some light on it? Any help is appreciated.

Nov 26, 2020 20:14


I don't remember exactly how thise code

filter = filter.And(x => x.SiteId().Match("Site1_ID"));
filter = filter.And(x => x.SiteId().Match("CurrentSite_ID"));

will be translated into an elastic query but maybe you could try with

filter = filter.And(x => x.SiteId().In(new[] {"Site1_ID", "CurrentSite_ID"}));
Dec 02, 2020 11:45

I know this is an old thread, but I had a hard time with this as well.  Bartosz, did you ever find a solution?

This is something that may help with that. I used the solution presented here to search multiple subsites.*qin1fn*_ga*NzQ5Njk3MTMxLjE2NjEzNTQ5NjU.*_ga_C7SLJ6HMJ5*MTY2NjgxMzY3Ni4zMy4xLjE2NjY4MTU1MDQuNjAuMC4w

Oct 31, 2022 15:21
* 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.