<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Connecting the Dots : Visualize Organize &amp;amp; Search</title><link>http://blogs.msdn.com/cheller/archive/tags/Visualize+Organize+_2600_amp_3B00_+Search/default.aspx</link><description>Tags: Visualize Organize &amp;amp; Search</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using ISearchQueryHelper from managed code</title><link>http://blogs.msdn.com/cheller/archive/2006/12/06/using-isearchqueryhelper-from-managed-code.aspx</link><pubDate>Thu, 07 Dec 2006 01:13:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1225460</guid><dc:creator>cheller</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/cheller/comments/1225460.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cheller/commentrss.aspx?PostID=1225460</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt; &lt;p&gt; &lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/aa965451.aspx"&gt;ISearchQueryHelper&lt;/a&gt; is a COM interface that can be used to convert from &lt;a href="http://msdn2.microsoft.com/en-us/library/aa965711.aspx"&gt;Advanced Query Syntax&lt;/a&gt; (AQS) to a SQL query that can be passed to the OLE DB Provider for Windows Search. (For background, see my previous post: &lt;a href="http://blogs.msdn.com/cheller/archive/2006/12/05/advanced-query-syntax-what-where-why-and-how.aspx"&gt;Advanced Query Syntax: What, Where, Why, and How&lt;/a&gt;)&lt;/p&gt; &lt;p&gt;Good news for managed code developers - there's a type library&amp;nbsp;from which you can create an interop assembly (using the &lt;a href="http://msdn2.microsoft.com/en-us/library/tt0cf3sx(VS.80).aspx"&gt;tlbimp.exe&lt;/a&gt; tool).&amp;nbsp;You'll find the type library (it's called SearchAPI.tlb) in the Lib folder of the Windows SDK.&amp;nbsp;&lt;/p&gt; &lt;p&gt;Once you've generated an interop assembly and have added a reference to it from your managed code project, here are the necessary steps to convert from AQS to SQL syntax:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Instantiate the Search Manager  &lt;li&gt;Get the catalog manager for the system index  &lt;li&gt;Query the catalog manager for its corresponding query helper  &lt;li&gt;Convert an AQS string to a SQL query string&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Here's some C# code that shows how to convert an AQS string to a SQL query string (the code fragment assumes that &lt;font face="Courier New"&gt;aqsQuery&lt;/font&gt; is a string variable that contains&amp;nbsp;an AQS query):&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt; SearchAPILib;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;...&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#408080"&gt;CSearchManager&lt;/font&gt; manager = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#408080"&gt;CSearchManagerClass&lt;/font&gt;();&lt;br&gt;&lt;font color="#408080"&gt;CSearchCatalogManager&lt;/font&gt; catalogManager = manager.GetCatalog(&lt;font color="#800000"&gt;"SystemIndex"&lt;/font&gt;);&lt;br&gt;&lt;font color="#408080"&gt;CSearchQueryHelper&lt;/font&gt; queryHelper = catalogManager.GetQueryHelper();&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&amp;nbsp;sqlQuery&lt;/font&gt;&lt;font face="Courier New"&gt; = queryHelper.GenerateSQLFromUserQuery(aqsQuery);&amp;nbsp; &lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1225460" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cheller/archive/tags/Visualize+Organize+_2600_amp_3B00_+Search/default.aspx">Visualize Organize &amp;amp; Search</category></item><item><title>Advanced Query Syntax: What, Where, Why, and How</title><link>http://blogs.msdn.com/cheller/archive/2006/12/05/advanced-query-syntax-what-where-why-and-how.aspx</link><pubDate>Tue, 05 Dec 2006 21:56:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1212768</guid><dc:creator>cheller</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/cheller/comments/1212768.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cheller/commentrss.aspx?PostID=1212768</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;em&gt;What &lt;/em&gt;is Advanced Query Syntax and &lt;em&gt;where &lt;/em&gt;is it used?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Advanced Query Syntax (AQS)&amp;nbsp;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).&amp;nbsp; &lt;/p&gt; &lt;p&gt;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&amp;nbsp;word "Vista". &amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;Vista author:catherine kind:email sent:today&lt;/font&gt;&lt;/p&gt; &lt;p&gt;For information on the specifics of the syntax, check out the &lt;a href="http://msdn2.microsoft.com/en-us/library/aa965711.aspx"&gt;documentation&lt;/a&gt; on MSDN.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;em&gt;Why &lt;/em&gt;should I care about AQS?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;As a user (and developers are users too&amp;nbsp;:-), AQS can help you&amp;nbsp;find things faster on products that support&amp;nbsp;AQS.&amp;nbsp;For example, on Windows Vista with Outlook 2007, I can enter the above query directly in the Start menu's instant search box! &lt;/p&gt; &lt;p&gt;As a developer, if you're using the OLE DB Provider for Windows Search&amp;nbsp;to run user-specified queries, you may want to consider supporting AQS.&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;em&gt;How&amp;nbsp;&lt;/em&gt;do I&amp;nbsp;support AQS in my application?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;There's no need to parse AQS yourself, just use the &lt;a href="http://msdn2.microsoft.com/en-us/library/aa965451.aspx"&gt;ISearchQueryHelper&lt;/a&gt;&amp;nbsp;interface. This interface&amp;nbsp;has a method called&amp;nbsp;&lt;a href="http://msdn2.microsoft.com/en-us/library/aa965439.aspx"&gt;GenerateSQLFromUserQuery&lt;/a&gt; that converts AQS to a SQL query that can be sent to the OLE DB Provider for Windows Search.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1212768" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cheller/archive/tags/Visualize+Organize+_2600_amp_3B00_+Search/default.aspx">Visualize Organize &amp;amp; Search</category></item><item><title>Windows Vista Search: Syntax Update</title><link>http://blogs.msdn.com/cheller/archive/2006/11/10/windows-vista-search-syntax-update.aspx</link><pubDate>Fri, 10 Nov 2006 18:35:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1054425</guid><dc:creator>cheller</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/cheller/comments/1054425.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cheller/commentrss.aspx?PostID=1054425</wfw:commentRss><description>&lt;p&gt;I recently learned some new things about the Search APIs in Windows Vista, including some&amp;nbsp;great improvements in the SQL syntax for the OLE DB Provider for Windows Search. (Thank you Chris McConnell - Architect on the Search team - for driving these changes, and for taking the time to explain them to me!). &lt;/p&gt; &lt;p&gt;There've been some simplifications in the syntax that happen to address a couple of things I found to be a bit odd and cumbersome:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;em&gt;System property names no longer require double quotes. &lt;/em&gt;Recall that the column names&amp;nbsp;specified in the SELECT statement must be properties from the Windows Vista property system; and since the naming convention for properties includes dots (&lt;em&gt;System&lt;strong&gt;.&lt;/strong&gt;Application&lt;strong&gt;.&lt;/strong&gt;Property&lt;/em&gt;), property names had to be delimited with double quotes. The double quotes are no longer necessary for system-defined properties (the ones that begin with &lt;strong&gt;System.&lt;/strong&gt;)  &lt;li&gt;&lt;em&gt;&lt;font face="ver"&gt;..SCOPE()&lt;/font&gt; no longer required in FROM statement. &lt;/em&gt;There is only a single catalog that can be searched on the desktop - and since scope is actually defined using the "Scope=" predicate in the WHERE clause -&amp;nbsp;you no longer need to add that funky "..SCOPE()" stuff at the end of the FROM clause. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;So, a query like this: &lt;/p&gt; &lt;p&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#0000a0"&gt;SELECT&lt;/font&gt; &lt;font color="#800000"&gt;"System.ItemName"&lt;/font&gt;, &lt;font color="#800000"&gt;"System.ItemUrl"&lt;/font&gt; &lt;font color="#0000a0"&gt;FROM&lt;/font&gt; &lt;font color="#0000a0"&gt;SYSTEMINDEX..SCOPE()&lt;/font&gt; &lt;/font&gt;&lt;/p&gt; &lt;p&gt;can now be written like this:&lt;/p&gt; &lt;p&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#0000a0"&gt;SELECT&lt;/font&gt; &lt;font color="#000000"&gt;System.ItemName, System.ItemUrl&lt;/font&gt; &lt;font color="#0000a0"&gt;FROM&lt;/font&gt; &lt;font color="#0000a0"&gt;SYSTEMINDEX&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Much better, isn't it?&lt;/p&gt; &lt;p&gt;(Note that these changes reflect added flexibility, and won't break any existing queries)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1054425" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cheller/archive/tags/Visualize+Organize+_2600_amp_3B00_+Search/default.aspx">Visualize Organize &amp;amp; Search</category></item><item><title>Windows Desktop Search 3.0 Released</title><link>http://blogs.msdn.com/cheller/archive/2006/10/25/windows-desktop-search-3-0-released.aspx</link><pubDate>Thu, 26 Oct 2006 02:17:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:874729</guid><dc:creator>cheller</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/cheller/comments/874729.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cheller/commentrss.aspx?PostID=874729</wfw:commentRss><description>&lt;p&gt;Windows Desktop Search (WDS) 3.0 has been released to the web. You can download it from one of the following links (depending on your OS version):&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4982072f-7660-492f-b96c-e42b4f5ab4aa&amp;amp;DisplayLang=en"&gt;Windows Desktop Search 3.0 RTW for Windows XP (KB917013)&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8dcc9ca3-1a14-43b9-b098-0479dc2865e7&amp;amp;DisplayLang=en"&gt;Windows Desktop Search 3.0 RTW for Windows XP x64 Edition (KB917013)&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=44be130c-631c-48bc-94a5-29dc704d608c&amp;amp;DisplayLang=en"&gt;Windows Desktop Search 3.0 RTW for Windows Server 2003 (KB917013)&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=afe0d86e-2257-442b-99f1-13fdbb9838c8&amp;amp;DisplayLang=en"&gt;Windows Desktop Search 3.0 RTW for Windows Server 2003 x64 Edition (KB917013)&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;&lt;em&gt;Why doesn't Windows Vista appear in this list?&lt;/em&gt;&lt;/strong&gt; Because the stuff that ships in WDS 3.0 is already built-in&amp;nbsp;to Windows Vista - there's no need to install it.&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;strong&gt;So if you're targeting Windows Vista (which I hope you are :-), why should you care?&lt;/strong&gt;&lt;/em&gt; You can think of WDS 3.0 as a "redistributable" for the Windows Vista "Visualize, Search &amp;amp; Organize" features that go down-level (e.g. the indexing platform, the property system, the OLE DB Provider for Windows Search). This enables you to target these features and still run on Windows XP, with the addition of WDS 3.0. Examples of applications that do this are Outlook 2007 and OneNote 2007.&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=874729" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cheller/archive/tags/Visualize+Organize+_2600_amp_3B00_+Search/default.aspx">Visualize Organize &amp;amp; Search</category></item><item><title>Windows Vista Search Syntax: WHERE are my predicates?</title><link>http://blogs.msdn.com/cheller/archive/2006/06/27/windows-vista-search-syntax-where-are-my-predicates.aspx</link><pubDate>Wed, 28 Jun 2006 02:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:649120</guid><dc:creator>cheller</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/cheller/comments/649120.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cheller/commentrss.aspx?PostID=649120</wfw:commentRss><description>&lt;p class="MsoNormal"&gt;In my last &lt;a href="http://blogs.msdn.com/cheller/archive/2006/06/21/642220.aspx"&gt;post&lt;/a&gt;, I gave a quick overview of the query syntax for the OLE DB Provider for Windows Search that ships in Windows Vista. In this post, I'll go over some of the details of the predicates that can be used in the WHERE clause. &lt;/p&gt; &lt;p class="MsoNormal"&gt;Just a quick disclaimer: this post is meant to help you get started; it's not my intention to provide a complete reference of the entire syntax. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;Simple Predicates &lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Simple predicates include &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;LIKE&lt;/font&gt;&lt;/b&gt;, literal comparisons, and the &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;NULL&lt;/font&gt;&lt;/b&gt; comparison.&lt;/p&gt; &lt;p class="MsoNormal"&gt;Here are examples of the &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;WHERE&lt;/font&gt;&lt;/b&gt; clause, using simple predicates:&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;WHERE &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;&lt;strike&gt;"System.DisplayName"&lt;/strike&gt;&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt; &lt;font face="Courier New" color="#800000"&gt;"System.ItemNameDisplay"&lt;/font&gt; LIKE &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;'a%'&lt;/font&gt;&lt;/b&gt; &lt;br&gt;Returns all items whose name begins with the letter 'a'&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font color="#808080"&gt;[Updated on October 25, 2006 to reflect changes made to the property system since I wrote this post. The property System.DisplayName no longer exists; use System.ItemNameDisplay instead]&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New"&gt;&lt;font color="#000080"&gt;WHERE&lt;/font&gt; &lt;font color="#800000"&gt;"System.DateModified"&lt;/font&gt; &lt;font color="#000080"&gt;&amp;gt;=&lt;/font&gt; &lt;font color="#800000"&gt;'2006-06-01'&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;br&gt;Returns all items modified on or after June 1&lt;sup&gt;st&lt;/sup&gt;, 2006&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New"&gt;&lt;font color="#000080"&gt;WHERE&lt;/font&gt; &lt;font color="#800000"&gt;"System.ApplicationName"&lt;/font&gt; &lt;font color="#000080"&gt;IS NOT NULL&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;&lt;br&gt;Returns all items that have a value for System.ApplicationName&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;Full-Text Predicates &lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The full-text predicates, &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS&lt;/font&gt;&lt;/b&gt; and &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;FREETEXT&lt;/font&gt;&lt;/b&gt;, enable you to search for text within the contents and/or the properties of items. &lt;/p&gt; &lt;p class="MsoNormal"&gt;They both have a similar syntax:&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS&lt;/font&gt;&lt;/b&gt; | &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;FREETEXT&lt;/font&gt;&lt;/b&gt;&lt;font face="Courier New"&gt; &lt;b&gt;&lt;font color="#000080"&gt;('&lt;/font&gt;&lt;/b&gt;&lt;font color="#666666"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color="#666666"&gt;searchString&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#666666"&gt;&amp;gt;&lt;/font&gt;&lt;b&gt;&lt;font color="#000080"&gt;')&lt;/font&gt;&lt;/b&gt;&lt;/font&gt; searches within the contents of items&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS&lt;/font&gt;&lt;/b&gt; | &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;FREETEXT&lt;/font&gt;&lt;/b&gt; &lt;font face="Courier New"&gt;&lt;b&gt;&lt;font color="#000080"&gt;(&lt;/font&gt;&lt;/b&gt;&lt;font color="#666666"&gt;&amp;lt;column&amp;gt;&lt;/font&gt;&lt;b&gt;&lt;font color="#000080"&gt;, '&lt;/font&gt;&lt;/b&gt;&lt;font color="#666666"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color="#666666"&gt;searchString&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#666666"&gt;&amp;gt;&lt;/font&gt;&lt;b&gt;&lt;font color="#000080"&gt;')&lt;/font&gt;&lt;/b&gt;&lt;/font&gt; searches within a given property&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS&lt;/font&gt;&lt;/b&gt; | &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;FREETEXT&lt;/font&gt;&lt;/b&gt; &lt;font face="Courier New"&gt;&lt;b&gt;&lt;font color="#000080"&gt;(* , '&lt;/font&gt;&lt;/b&gt;&lt;font color="#666666"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New" color="#666666"&gt;searchString&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#666666"&gt;&amp;gt;&lt;/font&gt;&lt;b&gt;&lt;font color="#000080"&gt;')&lt;/font&gt;&lt;/b&gt;&lt;/font&gt; searches contents and all properties&lt;/p&gt; &lt;p class="MsoNormal"&gt;Here are some simple examples, using different combinations of the &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS&lt;/font&gt;&lt;/b&gt; predicate: &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font color="#000080"&gt;&lt;font face="Courier New"&gt;CONTAINS(*, &lt;font color="#800000"&gt;'Catherine'&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080"&gt; &lt;/font&gt;&lt;/b&gt;&lt;br&gt;will return all items that contain 'Catherine' in either its contents or in any of its properties. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS(&lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;"System.Author"&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt;, &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;'Catherine'&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt;)&lt;/font&gt;&lt;/b&gt; &lt;br&gt;will limit the search to the property specified as the first argument – in this case, System.Author.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS(&lt;font color="#800000"&gt;'Catherine'&lt;/font&gt;)&lt;/font&gt;&lt;/b&gt; &lt;br&gt;will limit the search to the item contents.&lt;/p&gt; &lt;p class="MsoNormal"&gt;Note the following:&lt;/p&gt; &lt;ul style="margin-top: 0in; margin-bottom: 0in" type="disc"&gt; &lt;li class="MsoNormal"&gt;The predicate argument is enclosed in parenthesis  &lt;li class="MsoNormal"&gt;The search string is always enclosed in single quotes  &lt;li class="MsoNormal"&gt;As we saw in the SELECT statement, column names are enclosed in double quotes  &lt;li class="MsoNormal"&gt;Searches are case-insensitive&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal"&gt;Regarding the format of &lt;font face="Courier New" color="#666666"&gt;&lt;b&gt;&amp;lt;searchString&amp;gt;, &lt;/b&gt;&lt;/font&gt;if you want to search for anything beyond a single word with no spaces, you will also need to use double quotes. This is in addition to the single quotes that enclose the entire condition. Here are some examples:&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS(' &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;"This is a phrase"&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt; ')&lt;/font&gt;&lt;/b&gt; &lt;br&gt;note that the&amp;nbsp;search phrase is within double quotes, and the entire argument within single quotes&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS(' &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;"Using a wildcard*"&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt; ')&lt;/font&gt;&lt;/b&gt; &lt;br&gt;uses * as a wildcard in the search string&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS(' &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;"Using"&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt; AND &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;"Boolean"&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt; OR &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;"operators"&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt; ')&lt;/font&gt;&lt;/b&gt;&lt;br&gt;will return items that contain the string 'using' &lt;i&gt;and &lt;/i&gt;the string 'boolean' &lt;i&gt;or&lt;/i&gt; the string 'operators'.&amp;nbsp; &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;CONTAINS(' &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;"This"&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt; NEAR &lt;/font&gt;&lt;font face="Courier New" color="#800000"&gt;"that"&lt;/font&gt;&lt;font face="Courier New" color="#000080"&gt; ')&lt;/font&gt;&lt;/b&gt;&amp;nbsp; &lt;br&gt;will return items that contain the string 'this' within approximately 50 words or less of the string 'that'.&amp;nbsp; &lt;/p&gt; &lt;p class="MsoNormal"&gt;Use &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;FREETEXT&lt;/font&gt;&lt;/b&gt; if you care about relevancy– it’s the only predicate that returns a meaningful rank value. (All other predicates return 0 or 1000, depending on the whether there was a match or not). (Hint: to get the rank value,&amp;nbsp;include System.Search.Rank in the select list) &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;Search Depth Predicates &lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Not sure what the official term for this group of predicates is, but the &lt;font face="Courier New" color="#000080"&gt;&lt;b&gt;SCOPE&lt;/b&gt;&lt;/font&gt; and &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;DIRECTORY&lt;/font&gt;&lt;/b&gt; predicates enable you to control the depth of the search. &lt;/p&gt; &lt;ul style="margin-top: 0in; margin-bottom: 0in" type="disc"&gt; &lt;li class="MsoNormal"&gt;The &lt;font face="Courier New" color="#000080"&gt;&lt;b&gt;SCOPE&lt;/b&gt;&lt;/font&gt; predicate will search a specific folder and all of its subfolders (sometimes referred to as &lt;i&gt;deep traversal&lt;/i&gt;).  &lt;li class="MsoNormal"&gt;The &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;DIRECTORY&lt;/font&gt;&lt;/b&gt; predicate will search a specific folder, without searching subfolders (or what’s sometimes referred to as a &lt;i&gt;shallow traversal&lt;/i&gt;).&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal"&gt;The syntax for these two predicates is the same: &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: navy; font-family: courier new"&gt;"SCOPE&lt;/span&gt;&lt;font color="#666666"&gt;&lt;span style="font-family: courier new"&gt; &lt;/font&gt;&lt;font color="#999999"&gt;|&lt;/font&gt;&lt;font color="#666666"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span style="color: navy; font-family: courier new"&gt;DIRECTORY" =&lt;/span&gt;&lt;span style="font-family: courier new"&gt;&lt;font color="#000080"&gt; '&lt;/font&gt;&lt;font color="#c0c0c0"&gt;(&lt;/font&gt;&lt;font color="#000080"&gt;file&lt;/font&gt;&lt;font color="#666666"&gt; &lt;/font&gt;&lt;font color="#c0c0c0"&gt;|&lt;/font&gt;&lt;font color="#666666"&gt; &lt;/font&gt;&lt;font color="#000080"&gt;mapi&lt;/font&gt;&lt;font color="#666666"&gt; &lt;/font&gt;&lt;font color="#c0c0c0"&gt;|&lt;/font&gt;&lt;font color="#666666"&gt; &lt;/font&gt;&lt;font color="#000080"&gt;csc&lt;/font&gt;&lt;font color="#c0c0c0"&gt;)&lt;/font&gt;&lt;font color="#000080"&gt;:&lt;/font&gt;&lt;font color="#999999"&gt;&amp;lt;path&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: #000080; font-family: courier new"&gt;'&lt;/span&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Here’s an example of a &lt;font face="Courier New" color="#000080"&gt;&lt;b&gt;SCOPE&lt;/b&gt;&lt;/font&gt; predicate that limits the search to the &lt;font face="Courier New"&gt;C:\Foo\Example&lt;/font&gt; folder:&lt;/p&gt; &lt;p class="MsoNormal" style="margin-right: -9pt"&gt;&lt;span style="color: navy; font-family: lucida console"&gt;"SCOPE"=&lt;/span&gt;&lt;font color="#800000"&gt;&lt;span style="font-family: lucida console"&gt;'file:C:/Foo/Example&lt;/span&gt;&lt;/font&gt;&lt;span style="color: #800000; font-family: lucida console"&gt;'&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-right: -9pt"&gt;To only search the root folder, here’s what the &lt;b&gt;&lt;font face="Courier New" color="#000080"&gt;DIRECTORY&lt;/font&gt;&lt;/b&gt; predicate would look like:&lt;/p&gt; &lt;p class="MsoNormal" style="margin-right: -9pt"&gt;&lt;span style="color: navy; font-family: lucida console"&gt;"DIRECTORY"=&lt;/span&gt;&lt;font color="#800000"&gt;&lt;span style="font-family: lucida console"&gt;'file:C:/Foo/Example&lt;/span&gt;&lt;/font&gt;&lt;span style="color: #800000; font-family: lucida console"&gt;'&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The syntax may seem a bit odd (or at least, it did to me); let me point out some of the details:&lt;/p&gt; &lt;ul style="margin-top: 0in; margin-bottom: 0in" type="disc"&gt; &lt;li class="MsoNormal"&gt;&lt;span style="color: navy; font-family: lucida console"&gt;"SCOPE"=&lt;/span&gt;  &lt;ul style="margin-top: 0in; margin-bottom: 0in" type="circle"&gt; &lt;li class="MsoNormal"&gt;The predicate is enclosed in double quotation marks (it’s case insensitive, so it doesn’t matter if you use upper or lower case) and followed by an equal sign&lt;/li&gt;&lt;/ul&gt; &lt;li class="MsoNormal"&gt;&lt;span style="color: #800000; font-family: lucida console"&gt;'file:C:/Foo/Example'&lt;/span&gt;&lt;font color="#800000"&gt; &lt;/font&gt; &lt;ul style="margin-top: 0in; margin-bottom: 0in" type="circle"&gt; &lt;li class="MsoNormal"&gt;The path string is enclosed in single quotation marks  &lt;li class="MsoNormal"&gt;The path string begins with the corresponding protocol (in this case, &lt;font face="Lucida Console" color="#800000"&gt;file&lt;/font&gt;) followed by a colon; it's not followed by the familiar //, as in URLs.  &lt;li class="MsoNormal"&gt;Forward slashes (/) are used in the path&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;A Couple of Closing Hints&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The Windows Vista search and indexing infrastructure shares a common lineage with the SharePoint Portal Server indexing technologies. I've found the &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/SPSSQLSyntaxOverview_SV01150569.asp?frame=true"&gt;SharePoint Portal Server Search SQL Syntax&lt;/a&gt; documentation to be quite useful in piecing together some of the syntax details. Just keep in mind that not everything is applicable to Windows Vista.&lt;/p&gt; &lt;p class="MsoNormal"&gt;Regarding the Windows Vista property system - there have been recent changes to some of the property names to improve clarity, so you may need to change your queries to run with post-Beta 2 releases.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=649120" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cheller/archive/tags/Visualize+Organize+_2600_amp_3B00_+Search/default.aspx">Visualize Organize &amp;amp; Search</category></item><item><title>Searching for Windows Vista Search?</title><link>http://blogs.msdn.com/cheller/archive/2006/06/21/642220.aspx</link><pubDate>Thu, 22 Jun 2006 02:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:642220</guid><dc:creator>cheller</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/cheller/comments/642220.aspx</comments><wfw:commentRss>http://blogs.msdn.com/cheller/commentrss.aspx?PostID=642220</wfw:commentRss><description>&lt;P&gt;A number of people have been asking about Windows Vista search and how to programmatically query the search engine. There's not a lot of documentation available yet (and this will obviously change as we near the release of Windows Vista). So in the meantime, here's a quick primer for those of you that would like to get started today. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Background&lt;BR&gt;&lt;/STRONG&gt;Windows Vista includes a built-in desktop indexing platform. You’ll see search integrated throughout Windows Vista, in all the Explorer windows and even in the Start menu. A number of Microsoft products are building on top of this infrastructure - like Outlook 2007 and OneNote 2007, just to name a couple.&lt;/P&gt;
&lt;P&gt;Your applications can also plug into this same infrastructure and query the index, by using the new OLE DB Provider for Windows Search. (There are also extensibility mechanisms by which you can expose data to the indexer, but I'll leave that for a future post)&lt;/P&gt;
&lt;P&gt;The Windows Vista search and indexing infrastructure will also be available as a download for Windows XP and Windows Server 2003. You can download the Windows Desktop Search 3.0 Beta Engine Preview&amp;nbsp;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=36e38453-6e20-4cf7-8bfc-1cac7f35da49&amp;amp;DisplayLang=en"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Using the OLE DB Provider for Windows Search&lt;BR&gt;&lt;/STRONG&gt;While there's a lot of information available on OLE DB, you won't get very far with that alone – you also need to know the specifics of the provider, like its connection string and its query syntax. (If you're using ADO.NET, just a reminder that you can use the types defined in the System.Data.OleDb namespace. If you don't know how to use an OLE DB provider, a good place to start would be the &lt;A href="http://msdn.microsoft.com/data"&gt;MSDN Data Access and Storage Developer Center&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;Here's the connection string for the OLE DB Provider for Windows Search:&lt;BR&gt;&lt;FONT face="Courier New" color=#000080&gt;"Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The query syntax is what I've found to be the trickiest part, and that's what I'll focus on for the rest of this post.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Statements&lt;/STRONG&gt;&lt;BR&gt;The OLE DB Provider for Windows Search supports a single statement: the SELECT statement. The provider was designed solely for read-only operations, so there's no need for INSERT, UPDATE or DELETE statements.&lt;/P&gt;
&lt;P&gt;The structure of the SELECT statement looks like this:&lt;BR&gt;&lt;FONT face="Courier New" color=#000080&gt;&lt;STRONG&gt;SELECT &lt;FONT color=#808080&gt;&amp;lt;properties&amp;gt;&lt;/FONT&gt; &lt;BR&gt;&amp;nbsp; FROM &lt;FONT color=#808080&gt;[machineName.]&lt;/FONT&gt;SYSTEMINDEX..SCOPE() &lt;BR&gt;&amp;nbsp; &lt;FONT color=#808080&gt;[&lt;/FONT&gt;WHERE &lt;FONT color=#808080&gt;&amp;lt;predicates&amp;gt;]&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;&lt;FONT color=#000080&gt;SELECT &lt;FONT color=#808080&gt;&amp;lt;properties&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#a9a9a9&gt;&amp;lt;properties&amp;gt;&lt;/FONT&gt;&amp;nbsp;represents a list of one or more comma separated "column" names, where the columns correspond to properties defined in the new Windows Vista property system. &lt;/P&gt;
&lt;HR/&gt;
&lt;EM&gt;A note about the new Windows Vista property system:&lt;/EM&gt;  Windows Vista has a new schema-based property system which defines the metadata that can be stored within files. Hundreds of system-defined properties will ship with Windows Vista and the property system is also extensible by custom file format providers.
&lt;UL&gt;
&lt;LI&gt;The documentation for &lt;A href="http://windowssdk.msdn.microsoft.com/en-us/ms630276.aspx"&gt;Property Description Schema&lt;/A&gt; in the SDK docs will give you a pretty good idea of how properties are defined. 
&lt;LI&gt;Documentation on the system-defined properties, while not yet available online, is available in the documentation installed with the Beta 2 release of the Windows SDK. Here's how to navigate to the docs for these properties: User Interface-&amp;gt;Windows Shell-&amp;gt;Shell Reference-&amp;gt;Shell Properties&lt;/LI&gt;&lt;/UL&gt;
&lt;HR/&gt;
&lt;P&gt;Here are a couple of details about the SELECT clause that may not be obvious:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The convention used for property names is: &lt;EM&gt;Publisher.Application.Property&lt;/EM&gt; 
&lt;LI&gt;Property names must be enclosed in double quotation marks (due to the period used in the naming convention) 
&lt;LI&gt;SELECT * is not supported, so you'll need to specify at least one property name&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080&gt;&lt;STRONG&gt;FROM &lt;FONT color=#808080&gt;[machineName.]&lt;/FONT&gt;SYSTEMINDEX..SCOPE()&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;The FROM clause is pretty straightforward; since there's only a single index that can be queried, there's only one possible variation: you can precede SYSTEMINDEX..SCOPE() with a machine name to execute a query against the local index of a remote machine. (You must be running Windows Vista or Longhorn Server on the remote machine, and there are configuration steps/permissions that must be done before this will work).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" color=#000080&gt;&lt;FONT color=#808080&gt;[&lt;/FONT&gt;WHERE &lt;FONT color=#808080&gt;&amp;lt;predicates&amp;gt;]&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;The optional WHERE clause supports a number of predicates.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Simple predicates: literal value comparisons (&amp;lt;,&amp;gt;,=) and LIKE 
&lt;LI&gt;Full-text predicates: CONTAINS and FREETEXT 
&lt;LI&gt;Search depth predicates: SCOPE and DIRECTORY&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In my next post, I'll cover some details about the predicates and I'll provide some specific examples of their usage.&lt;/P&gt;
&lt;HR/&gt;
&lt;FONT color=#808080&gt;Updated June 26, 2006: modified formatting (you should now be able to copy and paste the connection string into your code, without getting a runtime error from the "smart" quotes)&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=642220" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/cheller/archive/tags/Visualize+Organize+_2600_amp_3B00_+Search/default.aspx">Visualize Organize &amp;amp; Search</category></item></channel></rss>