Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I thought it would limit where you search, but when I tried to do something like this:

fullTextSqlQuery.SiteContext = new Uri("http://test.myUrl.com/nc/mySite");

It returned results from other sites besides mySite. I've seen MSDN's nearly useless explanation of:

Gets or sets the site URL for the search query.

What does this mean? What am I actually setting when I specify a SiteContext?

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

It appears that mySite is a subweb of a site collection. The SiteContext refers to the site collection, not a web (site), which may be why you are seeing results outside of your web site mySite.

So if you have a site collection at http://test.myUrl.com, and you specify http://test.myUrl.com/nc/mySite as SiteContext, it will still use the site collection base Url http://test.myUrl.com.

share|improve this answer
    
I believe that mySite is a site collection as well as the base site. Could this be confusing SharePoint? –  Abe Miessler Dec 22 '11 at 1:33
    
No, if mySite is a site collection, then the SiteContext should set the context of the query to your site collection only. –  Russell Dec 22 '11 at 1:36
add comment

The SiteContext property is not related to the scope of the query. It just specifies the alternate access mapping zone for the result urls. Otherwise, the results will always return urls for the default zone. You can set it as follows:

fullTextSqlQuery.SiteContext = new Uri(SPContext.Current.Site.Url);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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