+ All Categories
Home > Documents > Minneapolis Office Developer Interest Group (MODIG)

Minneapolis Office Developer Interest Group (MODIG)

Date post: 01-Jan-2016
Category:
Upload: xiomara-lamorena
View: 23 times
Download: 0 times
Share this document with a friend
Description:
Minneapolis Office Developer Interest Group (MODIG). April 22, 2008 The MOSS Search API. Mike Hodnick http://www.kindohm.com [email protected]. Agenda. Introduction Feature Presentation MOSS Search API Topic Discussion Random Stuff. User Group Goals. - PowerPoint PPT Presentation
39
Minneapolis Office Developer Interest Group (MODIG) Mike Hodnick http://www.kindohm.com [email protected] April 22, 2008 The MOSS Search API
Transcript
Page 1: Minneapolis Office Developer Interest Group (MODIG)

Minneapolis Office Developer Interest Group (MODIG)

Mike Hodnickhttp://[email protected]

April 22, 2008The MOSS Search API

Page 2: Minneapolis Office Developer Interest Group (MODIG)

Agenda

• Introduction • Feature Presentation

– MOSS Search API

• Topic Discussion• Random Stuff

Page 3: Minneapolis Office Developer Interest Group (MODIG)

User Group Goals

• Provide a community for SharePoint Developers• Share development knowledge• Exchange tips/tricks/other/free pizza

Page 4: Minneapolis Office Developer Interest Group (MODIG)

User Group Format

• Presentations– 1-2 per meeting– Hopefully Demo Heavy

• Highlights of Nifty Things• QA/Discussion/Random Things

Page 5: Minneapolis Office Developer Interest Group (MODIG)

Call for Cool Stuff

• Created something cool?– Send Screenshots or Videos

• We’ll try to feature some items here

Page 6: Minneapolis Office Developer Interest Group (MODIG)

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

Page 7: Minneapolis Office Developer Interest Group (MODIG)

Upcoming

• Next Meeting– May ?? (5:30pm)– Topic: Web Part Development

• MNSPUG– May 14 (9:00am – Noon)– Topic : TBD (sharepointmn.com)

Page 9: Minneapolis Office Developer Interest Group (MODIG)

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

Page 10: Minneapolis Office Developer Interest Group (MODIG)

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

Page 11: Minneapolis Office Developer Interest Group (MODIG)

scenario

Page 12: Minneapolis Office Developer Interest Group (MODIG)

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….

Page 13: Minneapolis Office Developer Interest Group (MODIG)

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)

Page 14: Minneapolis Office Developer Interest Group (MODIG)

Keyword Searches with the MOSS Search API

• Returns a ResultTableCollection– Contains ResultTables (ResultTable implements IDataReader)

• Query Syntax

Query Type Format Example

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

Page 15: Minneapolis Office Developer Interest Group (MODIG)

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

Page 16: Minneapolis Office Developer Interest Group (MODIG)

keyword query demo

Page 17: Minneapolis Office Developer Interest Group (MODIG)

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!

Page 18: Minneapolis Office Developer Interest Group (MODIG)

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 Condition Format

FREETEXT FREETEXT(Property, ‘[keywords]’)

CONTAINS CONTAINS(Property, ‘[keywords]’)

Exact Property Match [property] = [value]

Scope “Scope = ‘[scope name]’”

Page 19: Minneapolis Office Developer Interest Group (MODIG)

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

Page 20: Minneapolis Office Developer Interest Group (MODIG)

full text query demo

Page 21: Minneapolis Office Developer Interest Group (MODIG)

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

Page 22: Minneapolis Office Developer Interest Group (MODIG)

search metadata demo

Page 23: Minneapolis Office Developer Interest Group (MODIG)

Search Web Service

• http://server/_vti_bin/Search.asmx• Relevant methods

Method Returns

Query(string) Returns string xml of results

QueryEx(string) Returns DataSet of results

GetSearchMetadata() Returns DataSet of Scopes and ManagedProperties

Page 24: Minneapolis Office Developer Interest Group (MODIG)

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 Schemahttp://msdn2.microsoft.com/en-us/library/ms563775.aspx

Page 25: Minneapolis Office Developer Interest Group (MODIG)

search web service demo

Page 26: Minneapolis Office Developer Interest Group (MODIG)

Web Service vs. API Quirk

• StartRow– API – index starts at zero– Web Service – index starts at one

Page 27: Minneapolis Office Developer Interest Group (MODIG)

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

Page 28: Minneapolis Office Developer Interest Group (MODIG)

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

Page 29: Minneapolis Office Developer Interest Group (MODIG)

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

Page 30: Minneapolis Office Developer Interest Group (MODIG)

SPSearchBench UI demo

Page 31: Minneapolis Office Developer Interest Group (MODIG)

SharePoint Search Bench API

• Search class– Context Uri– SearchType– ApiSource– SearchText– Credentials (for web service calls)

Page 32: Minneapolis Office Developer Interest Group (MODIG)

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();

Page 33: Minneapolis Office Developer Interest Group (MODIG)

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();

Page 34: Minneapolis Office Developer Interest Group (MODIG)

SPSearchBench API demo

Page 35: Minneapolis Office Developer Interest Group (MODIG)

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)

Page 36: Minneapolis Office Developer Interest Group (MODIG)

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);

Page 37: Minneapolis Office Developer Interest Group (MODIG)

SPSearchBench FullTextBuilder demo

Page 38: Minneapolis Office Developer Interest Group (MODIG)

Resources

• Writing relevant Full Text queries:http://msdn2.microsoft.com/en-us/library/bb219479.aspx

• Query Packet XML Schema:http://msdn2.microsoft.com/en-us/library/ms563775.aspx

• SharePoint Search Bench:http://codeplex.com/SPSearchBench

• Microsoft.Office.Server.Search.Query Namespace:http://msdn2.microsoft.com/en-us/library/microsoft.office.server.search.query.aspx

Page 39: Minneapolis Office Developer Interest Group (MODIG)

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


Recommended