SCOPE and DIRECTORY Predicates

Folder depth predicates control the scope of a search by specifying a path and whether to perform a deep or shallow traversal. The following shows the syntax of the folder depth predicates:

... WHERE [{SCOPE | DIRECTORY}='<protocol>:[//{SID}/]<path>']

The predicate is followed by an equal sign. The path is exclosed in single quotes and must begin with a protocol and a colon (for example, file:, mapi:, or csc:). The SCOPE predicate performs a deep traversal of the path, including all subfolders, while the DIRECTORY predicate does a shallow traversal of only the folder specified. Like other Structured Query Language (SQL) restrictions, you can specify more than one folder depth restriction in a single query.

To query the local catalog of a remote computer, include the computer name before the catalog and a Universal Naming Convention (UNC) path on the remote computer in the SCOPE or DIRECTORY clause.

Examples

SELECT System.ItemName FROM SystemIndex WHERE SCOPE='file:C:/Files/Reports'

SELECT System.ItemName FROM SystemIndex WHERE DIRECTORY='file:C:/Files/Reports' 

SELECT System.ItemName FROM SystemIndex WHERE SCOPE='file:C:/Files/Published' OR SCOPE='file:C:/Files/Reports' AND NOT SCOPE='file:C:/Files/Reports/Confidential'

SELECT System.ItemName FROM zarasmachine.SystemIndex WHERE SCOPE='file://zarasmachine/C:/Files/Reports'

SELECT System.ItemURL FROM SystemIndex WHERE SCOPE='mapi://{S-1-5-21-2117521111-1604012920-1887927527-2285604}/Mailbox user/' AND CONTAINS('Microsoft')

The first SCOPE example searches the C:\Files\Reports folder and all its subfolders. The DIRECTORY example searches only the root folder C:\Files\Reports.

Note  The file system backslashes (\) become a URL-style slash marks (sometimes called forward slashes) (/).

Related Topics

Tags :


Community Content

Thomas Lee
local file URSs are wrong
In actuality one has to follow pattern: '<protocol>:[//{SID}/]<path>' which would lead to correct 'file:c:/Files/Report' scopes.
Nothing is going to be found if local file scopes are as quoted in this article.

Remote example is broken as well, should be share name only, and not a path with "c:" in it:
SCOPE='file://zarasmachine/Files/Reports' (given there is an indexed share \\zarasmachine\Files)
Tags : contentbug

Thomas Lee
the file: protocol syntax does not follow the spec, not no %20's
This page discuses the proper syntax that is not supported by Windows Search:
http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx
Tags :

Page view tracker