2

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?

2 Answers 2

0

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.

2
  • I believe that mySite is a site collection as well as the base site. Could this be confusing SharePoint? Commented Dec 22, 2011 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
    Commented Dec 22, 2011 at 1:36
1

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);

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.