Try our conversational search powered by Generative AI!

Filter By Site Id in Unified Search


I've got a multi site set up and I want to be able to filter by site id but this is not available for me in unified search?

What's the best approach for this?


Jun 11, 2018 12:06

You could try using SearchHitUrl to determine if the page is coming from the correct site.  Not sure if there is a more efficient way of doing it?

Jun 11, 2018 12:11

Hi, if you are using Episerver Find there is a filter method you can use 'FilterOnCurrentSite'.

If you are not using Episerver Find then possibly use 'FilterForVisitor' this will filter on the current language, access rights, exclude container pages, exclude content folders and filter on current site.

Edited, Jun 11, 2018 12:29

Hi Paul,

This didn't work as the search is unified search and FilterOnCurrentSite will only return IContentData.

Jun 11, 2018 12:37

Hi Martin,

So you are using Episerver Find, did you try using 'FilterForVisitor'?

Something like this might be what you are looking for:

ITypeSearch<ISearchContent> query = _client.UnifiedSearchFor(searchText);

var TypeFilter = _client.BuildFilter<PageData>().FilterForVisitor();

query = query.Filter(TypeFilter);

var results = query.GetResult();

return results;

You might be able to implement your own custom filter:


[Pasting files is not allowed]

Edited, Jun 11, 2018 12:47

Hi Paul,

Thanks this got us to what we wanted.

Instead of the FilterForVisitor extension method we used FilterOnCurrentSite.

var siteFilter = _searchClient.BuildFilter<PageData>().FilterOnCurrentSite();

var query = querySearch
                .TermsFacetFor(x => x.SearchSection)
                .FilterFacet(AllSections, x => x.SearchSection.Exists())


Jun 11, 2018 13:49

Hi Martin,

Glad you got it sorted.


Jun 11, 2018 13:53
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.