FROM Clause

Use the FROM clause to specify the files on which to perform the search. The FROM clause defines the query scope.

Syntax

FROM [ Catalog_Name.. ] { SCOPE( [ 'Scope_Arguments' ] ) | View_Name }

Elements

Catalog_Name..  

Specifies the catalog to use. A catalog is the highest-level unit of organization in Microsoft Index Server. Each catalog is a completely self-contained unit, containing an index and cached properties for one or more scopes (virtual directories).

   
SCOPE( )  

Specifies the SCOPE function, which is the main component of the FROM clause. The SCOPE function can take zero or more comma-separated Scope_Arguments (that is, Traversal_Type and Path combinations).

You can specify SCOPE with an empty argument list, or (). This is the default scope that uses the virtual root ( / ) as its path.

   
View_Name  

Specifies either a predefined view or a non-persistent view defined by using the CREATE VIEW statement.

Although the SCOPE function restricts the lifetime of the virtual table definition to the current query, you can use a CREATE VIEW statement to define combinations of properties and scope for use in subsequent queries. For more information, see the CREATE VIEW Statement.

The SQL Extensions also support a set of predefined views of Index Server properties that are often queried against.

   
Scope_Arguments  

Specifies the paths or virtual roots to be searched and how they will be traversed. Each Scope_Argument must be enclosed in single quotes.

The syntax is:

' [ Traversal_Type ] ( "Path" [ , "Path", ...] )'

You have two options to specify for Traversal_Type:

DEEP TRAVERSAL OF  

Searches the current directory plus all directories beneath the specified location.

SHALLOW TRAVERSAL OF  

Searches the current directory only.

You can group a set of directories or virtual roots for deep or shallow traversal. See examples 3 and 4.

If you do not specify Traversal_Type, the default is DEEP TRAVERSAL OF.

You can specify Path as physical directories, such as "d:\reports\year\97", or virtual roots such as "/annual/corporate". A scope definition can include multiple directory storage paths and multiple virtual roots. Enclose each Path with double quotes (to accommodate spaces in pathnames). If you specify more than one path, they must be comma-separated.

Note   If some, but not all, of the paths you specify do not exist, these invalid paths are ignored and the query is done using only the valid paths. If all the paths you specify are invalid, then the result set is always empty.

Examples

  1. The following example defines a deep traversal search (default scope). It searches for the word "smith" in the DocAuthor property for all files starting from the virtual root directory "/".

    
    SELECT DocAuthor, DocTitle
    FROM SCOPE() 
    WHERE CONTAINS(DocAuthor, 'smith') > 0
  2. The following example defines a shallow traversal of \Contracts\open on drive D (the top directory only) and all the subdirectories at /reports/year 97.

    
    SELECT DocAuthor, size,  DocTitle,  write 
    FROM SCOPE(' SHALLOW TRAVERSAL OF "D:\Contracts\open" ',
    		  ' DEEP TRAVERSAL OF "/Reports/Year 97" ') 
    WHERE CONTAINS(DocTitle, '"Contract Expenses"') > 0
    

    Since DEEP TRAVERSAL OF is the default traversal selection, its inclusion is optional. You may want to use it to increase readability of the statement.

    Note that single quoted strings are used to associate traversal type to a specific path or set of paths.

  3. The following example statements are equivalent, but the FROM clause of the latter is more verbose than the former. In the second example, extra parentheses are added around the paths to enhance readability.

    
    SELECT DocAuthor, size,  DocTitle,  write 
    FROM SCOPE(' "D:\Word97\specs", "E:\DAPI\specs"  ' )  
        WHERE CONTAINS(Contents, '"content search"') > 0
    
    SELECT DocAuthor, size,  DocTitle,  write 
    FROM SCOPE(' DEEP TRAVERSAL OF ( "D:\Word97\specs", 
        "E:\DAPI\specs" ) ')
        WHERE CONTAINS(Contents, '"content search"') > 0
  4. The following example obtains DocAuthor, size, DocTitle, write property information from files in all directories at and below /reports/1997 and /reports/1996 and from files in the E:\temp\reports and the E:\scratch directories that contain the phrase "development status".

    
    SELECT DocAuthor, size,  DocTitle,  write 
    FROM SCOPE(' "/reports/1997" , "/reports/1996" ',
    		  ' SHALLOW TRAVERSAL OF ( "E:\temp\reports","E:\scratch") ') 
    WHERE CONTAINS(CONTENTS, '"development status"') > 0
    

© 1997 by Microsoft Corporation. All rights reserved.