开发者

What's the search scope of a FullTextSqlQuery

开发者 https://www.devze.com 2022-12-15 17:57 出处:网络
I\'m trying to use FullTextSqlQuery in to find a list of sharepoint sites a user has access to. Here\'s my code:

I'm trying to use FullTextSqlQuery in to find a list of sharepoint sites a user has access to. Here's my code:

SPFarm farm = SPFarm.Local;

SPWebServiceCollection webServices =
    new SPWebServiceCollection(farm);

foreach (SPWebService webService in webServices)
{
    foreach (SPWebApplication webApp in webService.WebApplications)
    {
        using (FullTextSqlQuery fullTextSqlQuery = new
            FullTextSqlQuery(ServerContext.GetContext(webApp)))
        {
        // Do some Initializtion
        fullTextSqlQuery.QueryText = 
            "select title, path from scope() where (contentclass = 'STS_Web' or contentclass = 'STS_Site') order by path";

           // execute the query and gather results
        }
    }
}

I naturally thought the search scope of an FullTextSqlQuery is defined by the argument of the constructor, as a web application would be the search scope in this case:

FullTextSqlQuery fullTextSqlQuery = new FullTextSqlQuery(ServerContext.GetContext(webApp))

However, for each web application, the query returns exactly the same res开发者_开发百科ult, which means webApp is not used as a scope. So where how I define a scope for a query?

Thanks.


The scopes are defined (either out of the box or custom) in the Shared Service Provider your web app is using. In the site collection settings of yoru site you can further specify allowed and used scopes.

The Shared Service Provider is found in the Central Admin's left menu, then, once in the ssp admin site, you can add, modify and delete Search Scopes.

More info here.

0

精彩评论

暂无评论...
验证码 换一张
取 消