SharePoint 2013 Search Based Solutions

25
SHAREPOINT AND PROJECT CONFERENCE ADRIATICS 2013 ZAGREB, NOVEMBER 27-28 2013 SharePoint 2013 Search Based Solutions Many ways to query SharePoint Search DARKO MILEVSKI, NEXTSENSE

description

Search-driven solutions are applications that use a search engine to drive the data access and present results. Microsoft SharePoint 2013 offers developers new ways to extend search to create search-based solutions and Apps. Using Search applications, developers can unite and control data from different site collections and external locations. In this session, I will cover all different ways of querying SharePoint 2013 Search including Client-Side Object Model (CSOM) and REST API. The main goal of the session is to provide strong understanding of search-driven solutions for the attendees and encourage many new ideas for using search to deliver end-user productivity.

Transcript of SharePoint 2013 Search Based Solutions

Page 1: SharePoint 2013 Search Based Solutions

SHAREPOINT AND PROJECT CONFERENCE ADRIATICS 2013

ZAGREB, NOVEMBER 27-28 2013

SharePoint 2013 Search Based SolutionsMany ways to query SharePoint SearchDARKO MILEVSKI, NEXTSENSE

Page 2: SharePoint 2013 Search Based Solutions

sponsors

Page 3: SharePoint 2013 Search Based Solutions

http://darkomilevski.info

Page 4: SharePoint 2013 Search Based Solutions

Agenda• SharePoint 2013 Enterprise Search Overview

• Keyword Query Language Overview

• Developing Server Side Search• Managed Server Side Object Model

• Demo

• Developing Client Side Search• Managed Client Side Object Model

• Demo

• JavaScript Client Side Object Model

• Demo

• REST APIs

• Demo

Page 5: SharePoint 2013 Search Based Solutions

What about search?• Are you using Bing or Google?• If you are a Dev, how many times have you tried to

develop without using a search engine?• Was it good experience?• Are using Search in SharePoint?• Did you know that you can customize and develop over

the SharePoint Search?• Do you know about rich Search functionalities like

Managed Properties, Result Sources, Query Rules, Keyword Query Language, etc., ….

Page 6: SharePoint 2013 Search Based Solutions

SharePoint 2013 Enterprise Search• Search in 2010 + FAST Search Server• Single Search• Server vs. Foundation• No more Express edition

• Deprecated Features• SQL Full-Text Query syntax -> Keyword Query Language• Search Scopes -> Result Sources

• Search Schema• Managed Properties

Page 7: SharePoint 2013 Search Based Solutions

Search Schema• Query data according to their metadata• Crawled and Managed Properties• OOTB Managed Properties• Author, Write (Modified Date), Path, FileSize, FileExtension,

and more

• Create your own managed properties• Maps to your own site columns• Crawled properties created automatically with owa_ prefix• Managed at Search Schema at SA or Site Collection• Map Managed property with one or more Crawled properties• Recrawl after mapping properties

Page 8: SharePoint 2013 Search Based Solutions

Result Sources• Replaces scopes (now deprecated)• Narrowing results• One very good explanation what are Result

Sources “imagine that your search index is the cube in the image on the slide, where you have four result sources:• Result source 1: search results can come from the

entire cube.• Result source 2: search results can come only from

the Bs.• Result source 3: search results can come only from

the Cs.• Result source 4: search results can come only from

the Ds.

• Query Transformation• {searchTerms} path:http://intranet/sales

Page 9: SharePoint 2013 Search Based Solutions

Keyword Query Language (1)• A KQL query consists of one or more of the following

elements:• Free text-keywords—words or phrases• Property restrictions

• Free text keywords• Word• Phrase• Operators and wildcard• Ex: conference / adria* / …

•  Property restrictions• <Property Name><Property Operator><Property Value>

Page 10: SharePoint 2013 Search Based Solutions

Keyword Query Language (2)• Use wildcard operator (*) to find more results

• i.e.: account* finds account, accounts, accountant, and accounting

• Use >, >=, <, <= operators to query results by date• i.e.: Write>=“1/1/2013”

• Query by managed property like author or title:• i.e.: Author:”Ian Peterson”• i.e.: Title:”Europe 2014”• i.e.: author:Shakesp*• i.e.: title:"Advanced Search“• i.e.: title:"Advanced Sear*“ - wildcard operator (*) in the query, and it is

supported only at the end of the phrase• i.e.: author:"John Smith" author:"Jane Smith“ = author:"John Smith" OR

author:"Jane Smith“• i.e.: author:"John Smith" filetype:docx = author:"John Smith“ AND filetype:docx

Page 11: SharePoint 2013 Search Based Solutions

SHAREPOINT SEARCH CENTER

Page 12: SharePoint 2013 Search Based Solutions

Developing SharePoint 2013 Search solutions

• Server Side or Client Side query execution• Scenarios in Demos: Searching Invoices• Narrow invoices by Result Source that search for certain

Content Type• Search by term or property restriction• Async query execution• Select Properties and Sorting• Results limit and Paging

Page 13: SharePoint 2013 Search Based Solutions

Server Side Managed OM Querying• Executed directly on the server• Used for full trust code• Use KeywordQuery class with SearchExecutor class• Use KQL for query text• Iterate ResultsTable of type RelevantResults

Page 14: SharePoint 2013 Search Based Solutions

SERVER-SIDE OM SEARCH

Page 15: SharePoint 2013 Search Based Solutions

Managed Client Side Object Model (CSOM)

• SharePoint Managed Client Side Object Model classes• Very similar classes and code like server side managed

object model• Familiar programming from CSOM back in SP2010• Use ExecuteQuery• Select Properties• Selecting Custom Managed Properties

• Sort List

Page 16: SharePoint 2013 Search Based Solutions

MANAGED CLIENT-SIDE OBJECT MODEL SEARCH

Page 17: SharePoint 2013 Search Based Solutions

JavaScript CSOM Search• JavaScript in SharePoint 2013 is derived from the .NET

server programming model, and the programming capabilities defined here reflect those found in the original .NET server source.• Reference .js files

• <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>• <script type="text/javascript" src="/_layouts/15/sp.js"></script>• <script type="text/javascript" src="/_layouts/15/sp.search.js"></script>

• Use ExecuteQueryAsync(OnSucess,OnFail)• Using Result Source

• Query Only Documents of certain Content Type• Sorting

• Search Paging

Page 18: SharePoint 2013 Search Based Solutions

CLIENT-SIDE SEARCH FROM JAVASCRIPT

Page 19: SharePoint 2013 Search Based Solutions

SharePoint 2013 REST APIs• SharePoint 2013 adds the ability to remotely interact

with SharePoint sites by using REST• Construct a RESTful HTTP request, using the Open Data

Protocol (OData) standard• Response is either Atom or JSON

Page 20: SharePoint 2013 Search Based Solutions

Search REST APIs• [site]/_api/[name of SP API]/[name of operation]?

[parameters]• http://intranet/_api/search/query?querytext='invoice'

Operation Sample REST URL

Use a search Result Source (i.e. a scope)

/_api/search/query?querytext='search term'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31' 

Specify a start row (i.e. in paging)

/_api/search/query?querytext='search term'&startrow=11

Specify a number of results to return

/_api/search/query?querytext='search term'&startrow=11&rowlimit=10

Specify particular (managed) properties to return

/_api/search/query?querytext='search term'&selectproperties='Author,Path,Title,Url'

Page 21: SharePoint 2013 Search Based Solutions

REST search calls• Create HttpWebRequest • Await for HttpWebResponse and the Load

ResponseSretam• Result parsing• OAuth authentication for remote apps

Page 22: SharePoint 2013 Search Based Solutions

REST

Page 23: SharePoint 2013 Search Based Solutions

Why to use Search in solutions• Site Collections consolidation• Security Trimming (Custom Security Trimming)• Fast query results• High Availability and Load Balancing

Pros Cons

• Search Features• Programmability possibilities• Fast results• Use refiners• Querying Index on disk, not in

SQL

• Time from data entry till crawl• Additional space on disk

Page 24: SharePoint 2013 Search Based Solutions

questions?

HTTP://DARKOMILEVSKI.INFO

@DARKOMILEVSKI

i

Page 25: SharePoint 2013 Search Based Solutions

thank you.

SHAREPOINT AND PROJECT CONFERENCE ADRIATICS 2013

ZAGREB, NOVEMBER 27-28 2013