Overview of the Search Query

The Microsoft SharePoint Portal Server Search (SharePointPSSearch) query is similar to a standard SQL query, as shown in the following syntax:

SELECT <columns>
FROM <catalogs>
WHERE <conditions>
RANK BY <conditions>
ORDER BY <columns>

In the following query example, the document size, title, and relevance ranking are returned for documents that are larger than 10,000 bytes long and are part of the Portal Content scope. Each matching file is assigned the rank value of 1000 by SharePointPSSearch, and the results are sorted in ascending size order.

SELECT
"DAV:getcontentlength",
"urn:schemas-microsoft-com:office:office#Title",
"Rank"
FROM Portal_Content..Scope()
WHERE ("DAV:getcontentlength" > 10000)
ORDER BY "DAV:getcontentlength"

The SharePointPSSearch query syntax supports many options, enabling more complicated queries.

The following table describes each clause in the SELECT statement, and the features it supports.

Clause Description
SELECT Specifies the columns returned by the query.
FROM Specifies the location to search. You can request that SharePointPSSearch check for matching documents in a given content index, in the specified folder only, or the specified folder and in all subfolders. By using the COALESCE_TABLE function, you can request that the query return the results of the first matching search from more than one search. By using the UNION ALL element you can search across content indexes.
WHERE Specifies what constitutes a matching document. This clause has many options, enabling rich control over the search conditions. For example, you can match against words, phrases, inflectional word forms, strings, numeric and bitwise values, and multi-valued arrays. You can also apply statistical weights to the matching conditions, and combine matching conditions with Boolean operators.
RANK BY Specifies modifications to the normal methods for calculating rank. Allows you to specify weights for specific matching conditions, and to multiply or add values to the normal calculated rank results.
ORDER BY Specifies the sort order for the results returned by the query. You can specify more than one field on which the results are sorted, and you can use ascending or descending ordering.