kql and the content search web part

33
KQL AND THE CONTENT SEARCH WEB PART (CSWP) IT Pro Solutions leveraging SharePoint 2013 search abilities (and KQL,REST and jQuery).

Upload: innotech

Post on 16-Jul-2015

121 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Kql and the content search web part

KQL AND THE CONTENT

SEARCH WEB PART (CSWP)IT Pro Solutions leveraging SharePoint 2013

search abilities (and KQL,REST and jQuery).

Page 2: Kql and the content search web part

ABOUT ME: PAUL MCCOLLUM

SharePoint Platform Manager at 7-Eleven Inc.

MCITP SharePoint 2010, MCTS SQL Server, SP 2007,WSS

@SharePointShark (www.sharepointyesNO.net)

Programming since 1978

Technology Evangelist/Forecaster

www.everythingUSB.com

www.ohGizmo.com

Solution Architect

JavaScript sub-guru

Intranet Platform Manager/Governance/Solution Architecture

{paul_mccollum}AT{Hotmail}

Page 3: Kql and the content search web part

LEANING INTO A NEW ERA

Content Creation Explosion

The ease of SharePoint turned many people and businesses into content publishing machines.

And in many cases the machines turned into monsters.

People didn’t understand Content Governance.

Search is similar.

Due to the technology of the time:

Content loading was slow

Search was SLOWER and resource intensive.

No need for concepts like tagging or SEO.

Page 4: Kql and the content search web part

BUT…

We still handle search with tongs like we are worried it's going to

break again.

There's usually ONLY:

A search page.

A search box.

I’m so

lonely.

Page 5: Kql and the content search web part

WHY AREN’T WE LEVERAGING

SEARCH MORE?

Since search data is cached well, the heavy lifting is done by the

crawl.

Search queries can actually be more performant than those from

native data.

This gives us a reason to take a second look at content we

surface and see if it could be improved with search data.

With FAST Search in SharePoint we can now look at Search as a

Primary Data Source

Page 6: Kql and the content search web part

CONTENT SEARCH WEB PART

The Content Search Web Part is one of the easiest ways to start

“turning the corner” to grab and correlate data to provide more

useful information to the user.

With CSWP you can very easily coalesce topic based information

and not be as worried about the source or physical location of the data.

Currently working in o365 (November 2013)

Page 7: Kql and the content search web part

CSWP, KQL AND DISPLAY TEMPLATES

Now that we see a little bit of the technology change, we can start to look at making use of it to power mini-applications.

Content Search Web Part

Simple and Wizard driven.

KQL

A pseudo-language and syntax to refine search queries beyond the Wizard.

No more CAML

Display Templates

HTML formatting, no XSLT

Can be extended with JavaScript and jQuery.

REST Connectors

Use as a raw data source for apps

No more CAML

Page 8: Kql and the content search web part

OUT OF THE BOX,

IT LEAVES A LOT TO BE DESIRED.

Page 9: Kql and the content search web part

HOWEVER, THE QUERY WIZARD IS

PRETTY AWESOME

Page 10: Kql and the content search web part

CSWP : EXAMPLES

Demo: Create CSWPs

Page 11: Kql and the content search web part

CSWP : EXAMPLES

Page 12: Kql and the content search web part

CSWP : VS. WMS

WMS (Work Management Service)

Limited

Fast

Tied to User Profile, Search and WMS Services

CSWP

Flexible

Predictable

Only dependent on Search Service

Page 13: Kql and the content search web part

KQL

KQL: The language of Search

2 types

Keyword

Generic word search

Word or Words

"a phrase“

* wildcard: works for words but only for the end of phrases

Property Filter

Targeted and Refined for specific columns or metadata

Page 14: Kql and the content search web part

KQL

Property Filtering (syntax) Author equals “John Smith”

<Property Name> <Property Operator> <Property Value>

author:"John Smith"

secondaryfiletype:docx

filename:budget.xlsx

Property Names must be Managed Fields in SharePoint

Unmanaged fields must be registered to show up in Search (Huge list available by default)

Property Operators

(numeric, int, DateTime) : = < > <= >= <> ..

(string/bool) : =

Other Operators

UNION AND (+) OR NOT (-) NEAR ONEAR

Page 15: Kql and the content search web part

KQL

Variables (from requestor context)

{Site.URL}

{Site.<property>}

{Page.URL}

{URLToken.<integer>}

{User.Name}

{User.Email}

{User.<property>}

Many more…. https://technet.microsoft.com/en-

us/library/jj683123.aspx

Page 16: Kql and the content search web part

KQL

Attributes (from result set)

https://technet.microsoft.com/en-us/library/jj219630.aspx

Page 17: Kql and the content search web part

KQL

Demo of KQL and config of CSWP

THEN *Audience Participation*

Page 18: Kql and the content search web part

EXAMPLES

Is my stuff getting old?

Author={User.Name} LastModifiedTime<{Today-65}

What have I been working on this week?

Author={User.Name} LastModifiedTime>{Today-5}

My ears are burning. Who’s talking about me?

Author<>{User.Name}AND( {User.LastName} OR {User.Email} )

Who’s messing with my Stuff?

Author={User.Name} ModifiedBy<>{User.Name}

Manage My Content

These files are too big.

Size>30000000

These files should only be on certain sites.

(SecondaryFileExtension=wmv OR SecondaryFileExtension=avi OR SecondaryFileExtension=mpg OR SecondaryFileExtension=asf OR SecondaryFileExtension=mp4 OR SecondaryFileExtension=ogg OR SecondaryFileExtension=ogv OR SecondaryFileExtension=webm)

These words really shouldn’t be on the site.

“Damn” “heck” “chick” “credit card” “SSN”

What’s new in HR this week?

path:"http://SITE/HR/" (IsDocument:"True" OR Contentclass:"STS_ListItem")LastModifiedTime>{Today-5}

Governance

Page 19: Kql and the content search web part

EXAMPLES: BONUS ROUND

(

SecondaryFileExtension=jpg

OR SecondaryFileExtension=gif

OR SecondaryFileExtension=bmp

OR SecondaryFileExtension=png

OR SecondaryFileExtension=tiff

OR SecondaryFileExtension=raw

)

“Mud” “soil” “earth”

Page 20: Kql and the content search web part

USEFUL ALONE OR IN GROUPS

Page 21: Kql and the content search web part

DISPLAY TEMPLATES : MECHANICS

Display Templates are very similar to the

CQWP XSLT templates.

An Outer Template calls a looping Inner

Template.

No longer XML and XSLT

HTML and JavaScript with ‘Server Side’

Substitution

Page 22: Kql and the content search web part

DISPLAY TEMPLATES : MECHANICS

To Access Display Template

• Map Network Drive

• Don’t need Designer

Page 23: Kql and the content search web part

DISPLAY TEMPLATES : CODE

Result Variable Column Mapping

Page 24: Kql and the content search web part

DISPLAY TEMPLATES : CODE

Variable Assignment

Display HTML

Page 25: Kql and the content search web part

DISPLAY TEMPLATES : EXAMPLES

Demo of Display Template alterations

Page 26: Kql and the content search web part

THE REST: WITH REST AND JQUERY

HTML vs .Net

Document Library

Versioning

No Compilation

Content Editor Web Part

Script Web Part

Cloud Friendly

Page 27: Kql and the content search web part

THE REST: WITH REST AND JQUERY

REST, HTML and jQuery

More Power

More Flexibility

Fewer Hoops

Page 28: Kql and the content search web part

THE REST: WITH REST AND JQUERY

Learning REST

POST or GET

Chrome’s Dev HTTP Client

Fiddler

Page 29: Kql and the content search web part

THE REST: WITH REST AND JQUERY

jQuery

Ajax

JSON

.each()

Page 30: Kql and the content search web part

THE REST: WITH REST AND JQUERY

Places to get ideas

DynamicDrive.com

JavascriptKit.com

Smashingapps.com

Page 31: Kql and the content search web part

THE REST: WITH REST AND JQUERY

Steps

Create query URL (REST)

Load into Array

Convert to HTML structure (if needed)

Wire-up to flashy plugin

Page 32: Kql and the content search web part

JQUERY APPS : EXAMPLES

Demo: Create REST Search mini App

Page 33: Kql and the content search web part

RESOURCES

KQL

http://msdn.microsoft.com/en-us/library/sharepoint/ee558911.aspx

http://msdn.microsoft.com/en-us/library/jj163973.aspx

Search Variables

http://technet.microsoft.com/en-us/library/jj683123.aspx

Default Crawled Properties

http://technet.microsoft.com/en-us/library/jj219630.aspx

Display Template Reference

http://technet.microsoft.com/en-us/library/jj944947.aspx

http://msdn.microsoft.com/en-us/library/jj945138.aspx

Codeplex sharepoint query tool.

REST Endpoints

http://msdn.microsoft.com/en-us/library/office/apps/jj860569.aspx

REST Programming

http://www.plusconsulting.com/blog/2013/05/crud-on-list-items-using-rest-services-jquery/

SharePoint Search REST API overview (http://server/_api/search/query?querytext='sharepoint')

http://msdn.microsoft.com/EN-US/library/sharepoint/jj163876.aspx

Working with Result data from REST calls

http://sharepointfieldnotes.blogspot.com/2013/01/sharepoint-2013-search-with-rest-app.html

Image Rotator

http://www.dynamicdrive.com/dynamicindex14/shockwave/index.htm