Search Request Format

The following example shows the syntax of a WebDAV SEARCH request.

SEARCH /myworkspace HTTP1.1
Host: server-dns-name
Content-Type: text/xml; Charset="UTF-8"
Content-Language: language-code
Connection: Close
Content-Length: content-length
Range: rows=rows-specifier
MS-SEARCH-MAXROWS: maxrows
MS-SEARCH-TOTALHITS: t | f
MS-SEARCH-USECONTENTINDEX: t | f
MS-SEARCH-IGNORENOISEONLY: t | f

<?xml version="1.0"?>
<DAV:searchrequest>
    <DAV:sql>
       sql-select-statement
    </DAV:sql>
</DAV:searchrequest>

The first line specifies the verb, the virtual path, and the protocol sent to the server.

SEARCH /myworkspace HTTP/1.1

The Host header indicates the Domain Name Server (DNS) name of the server computer.

Host: server-dns-name

The Content-Type header must be text/xml. To avoid character set encoding problems, set the Charset scheme to UTF-8.

Content-Type: text/xml; Charset="UTF-8"

The Language header indicates the country/region of the intended audience. If not specified, the value defaults to the system locale.

Content-Language: Language-code

The optional Connection header indicates whether the connection should be closed after the response is sent.

Connection: Close

The Content-Length header indicates the exact length of the request data block, in bytes. One blank line separates the last header from the request data.

Content-Length: content-length

The optional Range header indicates what rows from the result set to return. For more information, see the SharePoint Portal Server SDK section Requesting Row Ranges

Range: rows=rows-specifier

The optional MaxRows header indicates the maximum number of rows the server should search. Setting a MaxRows value will reduce unnecessary server processing.

MS-SEARCH-MAXROWS: maxrows

When set to true, the TotalHits flag returns the exact number of hits. The value is returned under the Content-Range header as total rows. The default setting is false.

MS-SEARCH-TOTALHITS: t | f

When set to true, the UseContextIndex flag will not use enumerations as part of its search criteria. The Search engine will only search the index. The default setting is false.

MS-SEARCH-USECONTENTINDEX: t | f

When set to true, the IgnoreNoiseOnly flag ignores noise words during its search criteria. The default setting is false.

MS-SEARCH-IGNORENOISEONLY: t | f

Note

All "MS-" headers have an effect only when the query is routed to the Search engine.

The first line of the request data block is the Extensible Markup Language (XML) document tag.

<?xml version="1.0"?>

The next tag opens the searchrequest element.

<DAV:searchrequest>

The sql tag opens the section containing the actual Structured Query Language (SQL) request.

    <DAV:sql>

Replace the next line with the text of the search query. The query statement must be in the form of a SharePoint Portal Server Search SQL Syntax. Remember to properly encode any special characters that will cause problems parsing the Extensible Markup Language (XML) data.

sql-select-statement

After the SQL query, close the sql tag, and then close the searchrequest tag.

    </DAV:sql>
</DAV:searchrequest>

Example

The following example shows a WebDAV request sent from the client to the server.

To avoid repeating DAV: throughout the request, you can assign a namespace alias for DAV:. This example uses that technique.

SEARCH /myworkspace HTTP1.1
Host: microsoft.com
Content-Type: text/xml
Content-Language: en
Connection: Close
Range: rows=0-99
MS-SEARCH-MAXROWS: 2000
MS-SEARCH-TOTALHITS: t
MS-SEARCH-USECONTENTINDEX: t
MS-SEARCH-IGNORENOISEONLY: t
Content-Length: 457

<?xml version="1.0"?>
<D:searchrequest xmlns:D = "DAV:" >
<D:sql>
        SELECT "DAV:getcontentlength", 
               "urn:schemas-microsoft-com:office:office#Title", 
               "urn:schemas.microsoft.com:fulltextqueryinfo:rank"
        FROM SCOPE ('DEEP TRAVERSAL OF "/myworkspace/documents"')
        WHERE ("DAV:getcontentlength" &gt; 10000)
        RANK BY COERCION ( Absolute, 1000 )
        ORDER BY "DAV:getcontentlength" DESC
    </D:sql>
</D:searchrequest>

The first line in the example is the SEARCH request to the WebDAV server. The Host line indicates the host computer, and the Content-Type line indicates the Multipurpose Internet Mail Extensions (MIME) type of the request content part, which must be "text/xml". The language type is en for English. The Connection line specifies to the server how to handle the connection after the request is completed. The Range line requests that the first 100 rows be returned, and the maximum number of rows to search is 2000. The TotalHits flag returns the actual number of hits up to the MaxRow value. The UseContextIndex flag does not enumerate during its search criteria. The IgnoreNoiseOnly flag ignores noise words as part of its search criteria. The Content-Length line indicates the exact length of the request data.

The request data follows one blank line, and is an XML document. The root element must be "DAV:searchrequest".

In the preceding example, the DAV namespace is mapped to "D" by using the xmlns namespace mapping in the search request element.

In the preceding SQL, three columns are requested: the document size, title, and rank. A row is returned for each document that is longer than 10,000 bytes, and is located on the server in the folder c:\documents, or in any subfolder under it. The results will all have the rank value 1,000, and are ordered in descending order by the document length. Because there is a Range header supplied in the request, only the first 100 documents are returned by this request.

Requesting Row Ranges

Search Errors Format

Search Response Format

Special Characters in the Request