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

Vote:
 

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"));
unifiedSearch.Filter(filter);
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?

#231012
Nov 17, 2020 14:01
Vote:
 

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.

#231392
Nov 26, 2020 20:14
Vote:
 

Dave,

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"}));
#232697
Dec 02, 2020 11:45
* 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.