Presentation is loading. Please wait.

Presentation is loading. Please wait.

Minneapolis Office Developer Interest Group (MODIG) Mike Hodnick April 22, 2008 The MOSS Search API.

Similar presentations


Presentation on theme: "Minneapolis Office Developer Interest Group (MODIG) Mike Hodnick April 22, 2008 The MOSS Search API."— Presentation transcript:

1 Minneapolis Office Developer Interest Group (MODIG) Mike Hodnick http://www.kindohm.com mike.hodnick@gmail.com April 22, 2008 The MOSS Search API

2 Agenda Introduction Feature Presentation – MOSS Search API Topic Discussion Random Stuff

3 User Group Goals Provide a community for SharePoint Developers Share development knowledge Exchange tips/tricks/other/free pizza

4 User Group Format Presentations – 1-2 per meeting – Hopefully Demo Heavy Highlights of Nifty Things QA/Discussion/Random Things

5 Call for Cool Stuff Created something cool? – Send Screenshots or Videos We’ll try to feature some items here

6 sharepointmn.com/modig Our current home Meeting information – Usually has the right time Previous presentations Running on SharePoint – As required by SharePoint User Group Law

7 Upcoming Next Meeting – May ?? (5:30pm) – Topic: Web Part Development MNSPUG – May 14 (9:00am – Noon) – Topic : TBD (sharepointmn.com)sharepointmn.com

8 MODIG T-Shirts http://www.cafepress.com/cp/customize/product.aspx?clear= true&number=%20253292961 http://www.cafepress.com/cp/customize/product.aspx?clear= true&number=%20253292961

9 Let’s dig in to the Search API… Very, very, very brief overview of MOSS Search features Scenario Keyword searches Full Text Searches Search Metadata Search Web Service SharePoint Search Bench I like to search

10 Very, very, very brief overview of MOSS Search Content Sources Crawled Properties Managed Properties Scopes Keyword Search Advanced Search – “full text search” Search Web Parts

11 scenario

12 What out-of-the-box MOSS Search CAN’T do… Drive app navigation Complex searches Execute searches in another app Custom UI layout/logic …and I thought that MOSS Search was so cool….

13 Keyword Searches with the MOSS Search API Microsoft.Office.Server.Search.Query.KeywordQuery Inherits from Query base class Constructed with an SPSite (or ServerContext) Properties of importance – QueryText (keywords) – StartRow – RowLimit – ResultTypes – SelectProperties (columns) – SortList (columns)

14 Keyword Searches with the MOSS Search API Returns a ResultTableCollection – Contains ResultTables (ResultTable implements IDataReader) Query Syntax Query TypeFormatExample Single keyword[keyword]Music Multiple keyword[keyword1] [keyword2]Music Guitar Keyword inclusion/exclusion+[keyword to include] –[keyword to exclude] +music –guitar Managed Property match[property]:[value]Artist:Helmet

15 Default ResultTypes Value ResultTypes property defaults to “None” To get results, you must set this property every time – Set to “RelevantResults” 99.999% of the time

16 keyword query demo

17 Full Text Searches with the MOSS Search API Microsoft.Office.Server.Search.Query.FullTextSqlQuery Inherits from Query base class (just like KeywordQuery) Constructed with an SPSite (or ServerContext) Properties of importance – QueryText – StartRow – RowLimit – ResultTypes Remember to set this value!

18 Full Text Searches with the MOSS Search API Returns a ResultTableCollection SQL Full Text style syntax http://msdn2.microsoft.com/en-us/library/bb219479.aspx SELECT Title, Author, Path, Rank FROM Scope() WHERE FREETEXT(DEFAULTPROPERTIES, ‘music guitar’) ORDER BY RANK DESC WHERE ConditionFormat FREETEXTFREETEXT(Property, ‘[keywords]’) CONTAINSCONTAINS(Property, ‘[keywords]’) Exact Property Match[property] = [value] Scope“Scope = ‘[scope name]’”

19 Specifying a Full Text Search Scope “FROM Scope()” has nothing to do with search scopes “FROM Scope()” cannot change To specify a scope, use a scope constraint in the WHERE clause SELECT Title, Author, Path, Rank FROM Scope() WHERE FREETEXT(DEFAULTPROPERTIES, ‘music guitar’) AND “Scope = ‘MusicLibrary’” ORDER BY RANK DESC

20 full text query demo

21 Search Metadata Managed Properties – Microsoft.Office.Server.Search.Query.Query class – Query.GetProperties() – PropertyInformation class Scopes – Microsoft.Office.Server.Search.Administration.Scopes class – Scopes.AllScopes property – Scope class

22 search metadata demo

23 Search Web Service http://server/_vti_bin/Search.asmx Relevant methods MethodReturns Query(string)Returns string xml of results QueryEx(string)Returns DataSet of results GetSearchMetadata()Returns DataSet of Scopes and ManagedProperties

24 Search Web Service Query() and QueryEx() methods receive a string parameter QueryPacket xml – Specify search type (Keyword vs. Full Text) – Specify properties found in FullTextSqlQuery and KeywordQuery classes QueryPacket Schema http://msdn2.microsoft.com/en-us/library/ms563775.aspx http://msdn2.microsoft.com/en-us/library/ms563775.aspx

25 search web service demo

26 Web Service vs. API Quirk StartRow – API – index starts at zero – Web Service – index starts at one

27 Search Llama asks: “How many values does a Boolean have?”

28 Difficulties with the MOSS Search API Differences between Keyword and Full Text On server vs. off server Full Text query syntax is ugly Pain to set up and debug searches – Trying out a search scope – Trying out a managed property

29 SharePoint Search Bench Open Source (CodePlex) Testing ground for searches Uses object model or web service Targets Keyword or Full Text SPSearch Bench API – Homogeneous search calls – Full Text query generator http://codeplex.com/spsearchbench

30 SPSearchBench UI demo

31 SharePoint Search Bench API Search class – Context Uri – SearchType – ApiSource – SearchText – Credentials (for web service calls)

32 SharePoint SearchBench API Object Model, Keyword search Search search = new Search(); search.ContextUri = new Uri(“http://server”); search.ApiSource = ApiSource.ObjectModel; search.SearchType = SearchTypes.Keyword; search.SearchText = new SearchText(“music”); DataSet results = search.Execute();

33 SharePoint SearchBench API Web Service, Full Text search Search search = new Search(); search.ContextUri = new Uri(“http://server/_vti_bin/search.asmx”); search.ApiSource = ApiSource.Service; search.SearchType = SearchTypes.FullText; search.SearchText = new SearchText(“Select Title ” + “, Author, Rank From Scope() Where “ + “FREETEXT(DEFAULTPROPERTIES, ‘music’) “ + “Order By Rank”); Search.Credentials = new NetworkCredential(…); DataSet results = search.Execute();

34 SPSearchBench API demo

35 SharePoint Search Bench Full Text Query Generation FullTextBuilder class – Select (adds columns) – Where (adds a constraint) – Order By Constraint class – Freetext – Contains – Property equality comparison –.Or(Constraint) –.And(Constraint)

36 FullTextBuilder Examples string fields = “Author, Title, Rank”; string keywords = “music”; FullTextBuilder output = FullTextBuilder.Select(fields).Where( Condition.FreeText(keywords)); string fields = “Author, Title, Rank”; string keywords = “music”; Condition c1 = Condition.FreeText(keywords); Condition c2 = Condition.Contains(“Author”, “John”); c1.And(c2); FullTextBuilder output = FullTextBuilder.Select(fields).Where(c1);

37 SPSearchBench FullTextBuilder demo

38 Resources Writing relevant Full Text queries: http://msdn2.microsoft.com/en-us/library/bb219479.aspx http://msdn2.microsoft.com/en-us/library/bb219479.aspx Query Packet XML Schema: http://msdn2.microsoft.com/en-us/library/ms563775.aspx http://msdn2.microsoft.com/en-us/library/ms563775.aspx SharePoint Search Bench: http://codeplex.com/SPSearchBench http://codeplex.com/SPSearchBench Microsoft.Office.Server.Search.Query Namespace: http://msdn2.microsoft.com/en- us/library/microsoft.office.server.search.query.aspx http://msdn2.microsoft.com/en- us/library/microsoft.office.server.search.query.aspx

39 It looks like you’ve reached the end. Would you like to…  Go home  Ask a question  Wake up  Don’t show this tip again


Download ppt "Minneapolis Office Developer Interest Group (MODIG) Mike Hodnick April 22, 2008 The MOSS Search API."

Similar presentations


Ads by Google