I have multiple sites on my Episerver. Now, when I search for anything on my search pages then it gets me results from both the sites. I would like to limit this. Is there any parameter that I can send in the query that would enable me to specify the website from which results should be returned?
I hope it makes sense. Can anyone help with this?
I think you can apply the Startpage condition inside the filter. Just retrieve the start page from sitedefintion and check the condition.
.Filter(x => x.Ancestors().Match(startpage.ContentLink.ID))
Ravindra's question is a good suggestion, however it should be changed slightly to this
.Filter(x => x.Ancestors().Match(ContentReference.StartPage.ToString()))
.FilterForVisitors() should already filter on current website. Every search document has a site ID property in the index. This filter will also handle expiry dates and permissions.
If you're using unified search then these filters are added to the query automatically, unless you specify that the search is not "public" (the parameter 'filterForPublicSearch' in .GetResult()).