2

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

1

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

http://melcher.it/search/results.aspx?**k**=SharePoint&**cs**=This%20List&**u**=http://melcher.it/sharepoint/lists/projects 

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/

1

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";
keywordQuery.SelectProperties.Add("Title");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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