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