OFF311 - Programming and Customizing Search in Microsoft Office SharePoint Server (MOSS) 2007Patrick TisseghemManaging Partner U2U
Session Prerequisites• Power User and/or Administration Skills MOSS
2007 Search Features• .NET Development• XML and XSLT Basic Skills
Session Objectives and Agenda• MOSS 2007 Search and Indexing Architecture• Search Administration Object Model• Customizing the Search Center• Programmatically Executing and Processing
Search Queries• Building and Deploying Custom Security
Trimmers
Index and Search Architecture
Web Sites
SharePoint Sites
Network Shares
User Profiles
Business Data
Lotus Notes
...
Protocol Handlers & IFilters
SearchDB
Property
Store
IndexFile
SSP SearchEngine
Search CenterSmall Search Box
IndexEngine
Search Object Model + Web Services + Custom Security Trimmers
Search Administration Object Model
Search Administration Tasks• Creating content sources• Defining crawl rules• Managing crawl schedules• Creating search scopes• Managing display groups to make search scopes
available in the scope pickers• Creating managed properties and making these
available in the advanced search pages• Managing best bets and keywords
Search Administration OM
ServerContext SearchContext
Content
Schema
Scopes
Keyword
Ranking
Propagation
LogViewer
Microsoft.Office.Server.Search.dll
Microsoft.Office.Server.dll
Server and Search Context• Use ServerContext class to connect to the
context of the Shared Services Provider
• Use SearchContext class to connect to the context of the Search Service
ServerContext srvctx = ServerContext.GetContext(SSPName);
SearchContext searchctx = SearchContext.GetContext(srvctx);
And then the Fun Starts...Build Apps for Admins...• Create content source to crawl business data• Start the crawl• Display the log entries• Create shared search scope • Make the scope available in display group in site
collection• Create managed properties• Make managed properties available in advanced
search page
DemoProgramming with the Search Administration Object Model
MOSS Search Center• Replace the search box with better user
experience
• Search Center with Tabs• Requires Office SharePoint Server Publishing
Infrastructure• Customizable by administrators and developers
• Search Center Lite• Does not require the publishing infrastructure• Use it to provide rich search experience in collection of
WSS sites• Also customizable but not as much as the one with
tabs
Search Center Page Layouts• OOB page layouts
• Searchmain.aspx• Searchresults.aspx• Peoplesearchresults.aspx• Advancedsearchlayout.aspx
• Create and provision custom page layouts• Add custom page layouts to list of available
page layouts for the Search Center
DemoCustom Search Center Page Layouts
Search Web Parts• Microsoft.Office.Server.Search.WebControls in
Microsoft.Office.Server.Search.dll
• Web Parts are sealed => you cannot inherit from them
• Expose many properties• Toolpane• Programmatic Access
• Connected with each other not with SharePoint Web Part connection infrastructure but with Query ID property
Web Parts on Search Pages• SearchBoxEx
• Scope picker• Additional query terms to append• Url for search results page• Url for advanced search page
• PeopleSearchBoxEx (Microsoft.SharePoint.Portal.dll)• Scope picker• Properties to include in search• Additional query terms to append• Url for people search results page
Web Parts on Results Pages• CoreResultsWebPart
• Paging settings• Duplicate results, search stemming and noise words
queries• Fixed queries and Scope• Selected Columns and Action links• XSLT
• PeopleCoreResultsWebPart• Inherits from CoreResultsWebPart
• CoreResultsWebPart class is also used for Search Action Links (with different XSLT and property settings)
Web Parts on Results Pages (continued)• SearchStatsWebPart
• Number of pages, total results and execution time• Query ID connects it to the core results Web Part
• SearchPagingWebPart• Labels, settings and possibly images for paging • Query ID connects it to the core results Web Part
• SearchSummaryWebPart• Summary info mode• Query ID connects it to the core results Web Part
• HighConfidenceWebPart• Display keywords and best bets• Query ID connects it to the core results Web Part
Web Parts on Advanced Search Page• AdvancedSearchBox
• Different search boxes• Language picker• Scope picker• ResultType picker• Property picker
DemoCustomizing and Programming with the Search Web Parts
XSLT• Rendering of
search results is driven by XSLT
• XSL and XSLLink property
• Base class is DataFormWebPart
DemoCustom XSLT for the Search Core Results Web Part
Custom Tabs• Tabs are stored as items in lists
• List for search pages• List for search results pages
• Connect tab to default or custom search page
DemoCustom Tabs for the Search Center
Search Query Object Model
Query Engine
Query Engine
DefinitionsResultTable- IDataReader
Relevance
High Confidence
Best Bets
Keyword syntax
SQL Syntax
QueryClient Application
Browser or ClientResults UI
Query Object Model & Web Service
Query Syntax• Keyword syntax
• New for building keyword queries• Use it for simple queries
• SQL syntax• Supports full-text searching• Extension of the SQL query syntax• Use it for complex queries
The Query Object Model
Query
FullTextSqlQuery
KeywordQuery
• Microsoft.Office.Server.Search.dll• Microsoft.Office.Server.Search.Query namespace
DemoCustom Search Box Web Part
The Search Web Service• Search.asmx
• Support for both syntaxes• Query Web Method• QueryEx Web Method• Additional methods to retrieve scopes and managed
properties
• Search Web Service = Research Web Service
• IE7 Search Provider
DemoRemote searching
Custom Trimmers• Do something (typically trimming) before the
results are shown to the user• Security trimming of search results• Trim based on business/context information
• ISecurityTrimmer Interface
• Registration via stsadm and the RegisterSecurityTrimmer option
DemoBuilding and Deploying Custom Security Trimmer
Resources• MS Press Books
• ‘Inside MOSS 2007’ (Patrick Tisseghem)• ‘Inside Indexing and Search Engine:
MOSS 2007’ (Patrick Tisseghem and Lars Fastrup)
• MSDN Enterprise Search Developer Centerhttp://msdn2.microsoft.com/en-us/office/bb335345.aspx
• MSDN Visual How-To’s on Search
MSDN Library Knowledge
Base Forums MSDN Magazine User
Groups Newsgroup
sE-learning
Product Evaluations Videos
Webcasts V-labs Blogs MVPs
Certification Chats
learnsupportconnectsubscribe
Visit MSDN in the ATE Pavilion and get a FREE 180-day trial of MS Visual Studio Team System!
Resources• Technical Communities, Webcasts, Blogs, Chats
& User Groupshttp://www.microsoft.com/communities/default.mspx
• Microsoft Learning and Certificationhttp://www.microsoft.com/learning/default.mspx
• Microsoft Developer Network (MSDN) & TechNet http://microsoft.com/msdn http://microsoft.com/technet
• Trial Software and Virtual Labshttp://www.microsoft.com/technet/downloads/trials/default.mspx
• New, as a pilot for 2007, the Breakout sessions will be available post event, in the TechEd Video Library, via the My Event page of the website
MSDN Library Knowledge
Base Forums MSDN Magazine User
Groups Newsgroup
sE-learning
Product Evaluations Videos
Webcasts V-labs Blogs MVPs
Certification Chats
learnsupportconnectsubscribe
Visit MSDN in the ATE Pavilion and get a FREE 180-day trial of MS Visual Studio Team System!
Complete your evaluation on the My Event pages of the website at the CommNet or the Feedback Terminals to win!
All attendees who submit a session feedback form within 12 hours after the session ends will have the chance to win the very latest HTC 'Touch' smartphone complete with Windows Mobile® 6 Professional
© 2007 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only.MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.