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?