My requirement is to search within sub site, if i am searching within a specific sub site result should come from current sub site. Here everything is working fine. But when I do advanced search it gives result from all site scope.

I can not create scope because we have more then 1000 sub site under one site collection and we have more then 50 site collections.

While I was looking at advanced search web part I don't see option for "Default to contextual scope" simile to search box web part.

I tried to set scope property of core result web part to "This Site" but its not working.

Note: I am not using FAST search

2 Answers 2


You have to pass the context url parameter u as query string. Example:


k = keyword
cs = contextual scope
u = contextual scope url

Here is an example how you can do something similar with JavaScript: http://joshmccarty.com/2011/05/sharepoint-contextual-search-updated/


I'm using KeywordQuery to Search. Add each column you want returned to the "SelectProperties".

SPWeb site = SPContext.Current.Web;
KeywordQuery keywordQuery = new KeywordQuery(site);

keywordQuery.QueryText = "Search Term";
  • could you please add more details about it.
    – Waqas Sarwar MVP
    Apr 6, 2016 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.