.NET Server

Creating WebDAV Server With Search Support (DASL)

In this article

Creating WebDAV Server With Search Support (DASL)

IT Hit WebDAV Server Engine supports WebDAV DASL compliant search.

ISearchAsync Interface

To enable search support, you must implement ISearch interface on folder items that support search. This interface provides a single method ISearch.SearchAsync that is called when Engine receives search request passing search phrase and search options:

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

In this method implementation, you will query your storage and return items that correspond to search request. You are free to return items found in a subtree, only in this folder or on the entire server, it totally depends on your implementation.

The SearchOprtions parameter contains 2 boolean flags that indicate where the search should be performed: in file content, file names or both.

When IT Hit Ajax Browser is used as a search client it will request file names search only when displaying pop-up hint:

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

When requesting search results both SearchOptions.SearchName and SearchOptions.SearchContent will be set to true.

Discovering DALS Search support

To find out if your server supports search feature, the WebDAV client will submit the OPTIONS request on folder. If the Engine discovers ISearch interface on that folder it will return SEARCH token in Allow header as well as DASL: <DAV:basicsearch> header.

See how IT Hit Ajax Browser is discovering Search support.

Examples of DASL Search Request

The WebDAV Engine supports DASL basic search. It can process fine content search request, file name search or both. Here is an example of search XML that searches for the word starting with “general” contained in file names or in file content:

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

You can find about search IT Hit Ajax Browser here.

Search Phrase Wildcards and Escaping

The DASL search phrase can contain wildcard characters and escape according to DASL rules:

  • ‘%’ – to indicate one or more character.
  • ‘_’ – to indicate exactly one character.

If ‘%’, ‘_’ or ‘\’ characters are used in search phrase they are escaped as ‘\%’, ‘\_’ and ‘\\’.

Example of Full-Text Search on Files Stored in File System

In the example below we will use the Windows file system indexing to search file names and file content. File system indexing can search file content, including Microsoft Office documents as well as any other documents, in case the search filter is installed in file system.

To enable search in file system, you must enable indexing on the folder where your files are located. See here how to enable indexing here.

Below is the ISearch interface implementation that is using SearchAsync.CollatorDSO provider to search file system:  

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

To see the complete code, examine the NtfsStorage sample or generate code using Visual Studio WebDAV wizards.

Example of Full-Text Search on Files Stored in Database

To search file content stored in Microsoft SQL database, including the content of Microsoft Office documents, you can use the Microsoft SQL full-text search.

To find out how to enable full-text search in the code generated by WebDAV Wizard for Visual Studio or in sample provided with SDK with SQL back-end read the Enabling Full-Text search for files stored in Microsoft SQL Database article.

Below you can see an example of the ISearch.SearchAsync implementation that queries SQL server:

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

This code is part of WebDAV Server File System sample provided with IT Hit WebDAV Server Engine for .NET

                            
                        

Note that for the sake of simplicity the SQL code is recursively searching folders under the search subfolder which may not be the best solution from the performance point of view.

See Also:

 

Next Article:

WebDAV Server Engine Request Processing Pipeline Customization