UNION ALL Scope Specifications

UNION ALL Scope Specifications

SharePoint Portal Server supports searching in multiple catalogs through the UNION ALL scope specification. The syntax for this is:

( <union_all_specifier> ) [AS]<scope_alias>

The union_all_specifier construct specifies the catalogs where the search is performed. Although the AS keyword is optional, a scope alias is required. The scope alias must be a valid regular or delimited identifier.

The union_all_specifier has the following syntax:

TABLE <qualified_scope> UNION ALL TABLE <qualified_scope> 
[ UNION ALL TABLE <qualified_scope> ]…

Each TABLE keyword specifies that the qualified scope is to be treated as a separate table. UNION ALL specifies that the two tables be combined in the UNION manner. Note that this is not the same as a database JOIN; a UNION effectively combines the two tables into a single table having all the rows and all the columns.

The search query can combine more than two search scopes by simply adding additional UNION ALL keywords and TABLE specifiers.

Examples

The following example FROM clause searches for documents in the top level of the Web site http://www.microsoft.com/windows, recursively through the local file catalog under file://server/documents, and in the top level of the file://server/FinancialReports directory. The Web site is indexed in the catalog named Websites, the Documents directory is indexed in the LocalDocuments catalog, and the FinancialReports directory is indexed in the Finance catalog.

FROM ( 
TABLE WebSites..SCOPE (' SHALLOW TRAVERSAL OF "http://www.microsoft.com/windows" ' )UNION ALLTABLE LocalDocuments..SCOPE (' DEEP TRAVERSAL OF "file://server/documents" ' )UNION ALLTABLE Finance..SCOPE (' SHALLOW TRAVERSAL OF"file://server/FinancialReports" ' ))

COALESCE_TABLE Function

FROM Clause