Advanced Query Syntax: What, Where, Why, and How

What is Advanced Query Syntax and where is it used?

Advanced Query Syntax (AQS) is a syntax that enables end-users to define targeted search queries, and is supported in a number of Microsoft products (for example: Windows Vista, Outlook 2007, and Windows Desktop Search). 

Here is an example of a search query defined using AQS that will return all the email items, sent by me today, that include the word "Vista".  

Vista author:catherine kind:email sent:today

For information on the specifics of the syntax, check out the documentation on MSDN.

Why should I care about AQS?

As a user (and developers are users too :-), AQS can help you find things faster on products that support AQS. For example, on Windows Vista with Outlook 2007, I can enter the above query directly in the Start menu's instant search box!

As a developer, if you're using the OLE DB Provider for Windows Search to run user-specified queries, you may want to consider supporting AQS. 

How do I support AQS in my application?

There's no need to parse AQS yourself, just use the ISearchQueryHelper interface. This interface has a method called GenerateSQLFromUserQuery that converts AQS to a SQL query that can be sent to the OLE DB Provider for Windows Search.