Writing Code To Interact With Enterprise Search


Published on

Slides from my talk at SharePoint Saturday Ozarks 2009 about writing code to interact with MOSS Enterprise Search.

Published in: Technology, Design
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Demo Keyword Query Syntax in Search Center
  • Demo query string syntax and RSS
  • Demo KeywordQuery class along with how to specify managed properties.
  • Demonstrate FullTextSqlQuery class.
  • Writing Code To Interact With Enterprise Search

    1. 1. Writing Code to interact with Enterprise Search<br />Corey Roth<br />Blog: www.dotnetmafia.com<br />Twitter: twitter.com/coreyroth<br />
    2. 2. Corey Roth<br />Consultant for Stonebridge<br />Worked in Consumer Electronics, Travel, Advertising, and Energy industries<br />Currently doing MOSS development specializing in Enterprise Search<br />Microsoft Award for Customer Excellence (ACE) Winner<br />MCTS: MOSS 2007 Configuring<br />E-mail: corey.roth@gmail.com<br />Twitter: twitter.com/coreyroth<br />Blog: www.dotnetmafia.com (mirrored on sharepointblogs.com)<br />
    3. 3. What is Enterprise Search?<br />Enterprise Search is one of Microsoft’s current offerings to do search in the Enterprise<br />Included in MOSS 2007<br />Also available as a stand alone product (Search Server 2008 / Search Server Express)<br />Allows for indexing and querying of documents from multiple sources (i.e.: documents, web sites, file shares, Active Directory (people), databases, web services, etc.)<br />
    4. 4. Interacting with Search<br />Search Center<br />Query String<br />RSS<br />KeywordQuery Class<br />FullTextSqlQuery Class<br />Web Service<br />
    5. 5. Keyword Query Syntax<br />Used to search by Managed Properties<br />Can specify Scopes (Scope:”MyScope”)<br />Does not support wildcard search<br />AND implied between each keyword (i.e.: Color:”Red” Size:”M” is the same Color=“Red” AND Size=“M”)<br />OR implied when multiple keywords of the same managed property used (i.e.: Color:”Red” Color:”Blue” translates to Color=“Red” OR Color=“Blue”)<br />Can Specify Content Sources (ContentSource:”My Source”<br />IsDocument:”1” – Query Documents Only<br />
    6. 6. URL Syntax<br />Search Center and RSS pages accept queries via the query string<br />Uses the keyword syntax specified on the K parameter (i.e.: results.aspx?k=Accounting)<br />Can specify scope using the S parameter (i.e.: results.aspx?k=Account&s=Corporate Documents)<br />Results can be paged with the start parameter<br />
    7. 7. KeywordQuery Class<br />SharePoint API class to execute a query using Keyword Syntax<br />Returns a ResultsTableCollection object which can be converted to a DataTable<br />Can only be used on the SharePoint server<br />Uses the credentials of the application executing the code (i.e.: the user who ran a console application, or the application pool account)<br />SelectProperties can be used to add custom managed properties. You must add all default properties as well as your own custom properties if this is used.<br />
    8. 8. Full Text SQL Syntax<br />T-SQL style method of querying Enterprise Search<br />Can be used to do a wildcard search<br />Specify columns in SELECT statement <br />SELECT Title, Path, Write, Rank,…<br />Always FROM Scope()<br />Note syntax when using WHERE with a Scope<br />WHERE “Scope” = ‘File Share’<br />CONTAINS predicate supports wildcard search, FREETEXT does not<br />ORDER BY clause can be used for ordering<br />See Office Server SDK for more information<br />
    9. 9. Web Services<br />Located on your SharePoint server in the _vti_bin virtual folder<br />/_vti_bin/search.asmx – Enterprise Search web service<br />/vti_bin/spsearch.asmx – WSS3 Search web service<br />Both use the same syntax<br />Web Service requires authentication<br />Specify using .Credentials property<br />Requires an input XML string<br />Query method returns an XML string<br />QueryEx method returns a DataSet<br />
    10. 10. Query Request Schema<br />Can use Keyword Query syntax or Full Text SQL Query syntax<br />QueryText element contains the query<br />type=“STRING” – Keyword Query<br />type=“MSSQLFT” – Full Text SQL Query<br />Range / StartAt/ Count elements can be used for paging<br />Properties element can be used to specify custom managed properties when using Keyword Query syntax<br />SortByProperties element sorts keyword queries<br />Note the casing of everything<br />
    11. 11. RSS<br />Can use the URL syntax with the RSS page at http://<moss-server>/<SearchCenterUrl>/_layouts/srchrss.aspx<br />Returns an XML document in RSS format containing search results<br />Will not return custom managed properties<br />
    12. 12. Questions?<br />Corey Roth<br />Blog: www.dotnetmafia.com<br />Twitter: twitter.com/coreyroth<br />