Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top