Thursday, March 27, 2014

S15E01: KQL – The Basics

Want the book? Go get it!

This is the first episode in my series “SharePoint Search Queries Explained - The Series”. See the intro post for links to all episodes.

SharePoint 2013 includes two query languages which can be used to formulate your search queries. The Keyword Query Language (KQL) and the FAST Query Language (FQL). KQL is the topic for episode 1 and 2, and is the language you will mostly use when writing search queries, and is aimed at end-users. FQL has some extended capabilities over KQL, but you will usually solve your queries using KQL. FQL is also trickier to execute using the UI/CSOM/REST, but more on that in episode 10.

Wednesday, March 26, 2014

RESTful way to retrieve the Search Center URL

On one of my daily Fiddler adventures I stumbled upon a REST end-point I hadn’t seen before in SharePoint Online (Does not currently work on-premises with 2013 sp1, but hoping it will arrive in an update).

/_api/search/searchcenterurl

The end-point is not documented or mentioned on MSDN, but is easy to use. You call it with a GET and get something like the following back in JSON

{"d":{"searchcenterurl":https://contoso.sharepoint.com/search/Pages}}

If you’re using jQuery you can get the search center url for the current site using the following code:

jQuery.ajax({
url: _spPageContextInfo.webServerRelativeUrl+"/_api/search/searchcenterurl",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
})
.done(function (data) {
alert(data.d.searchcenterurl);
});


A use case could be that you have a page with some tags displayed, and when clicking on the tags you want to execute a search from the search center on the clicked tag. By tacking on Results.aspx?k=<your query> to the returned URL you can easily redirect the user to the result page of your choice with a predefined query.

Tuesday, March 25, 2014

Using Tags as a Refiner

In my recent talk “Rock your SharePoint Online Search With 13 Easy Tune-Ups”, which I presented at SharePoint Saturday in Stockholm and will present again at the European SharePoint Conference in Barcelona, I talked about removing unwanted/unused refiners.

On that note I got contacted by Paul Hunt, who wondered about the Tags refiner which was out of the box in SharePoint 2010, but is not in 2013. In my opinion this refiner is seldom used. This could because it appears “below the fold” or under the screen you initially see, or that people don’t have a concept of tagging.

Either way, Paul has customers who found it very useful and who are used to tagging. The good news is that it’s very easy to add it back.

If you edit your search result page, then edit the Refinement Web Part, click Choose Refiners, add Tags to your list of refiners, and you should be all set.

image

Monday, March 24, 2014

Caveats when using Summary Link Web Part in a Web Template

My scenario was that the Summary Link Web Part had been used on a site which was to be saved as a site template using the UI (Save site as template). Saving the template worked fine, but once you created a new site based on the template you got the infamous “List does not exist” error.

The reason for the error is that the SummaryLinkWebPart class inherits the DataFormWebPart class, which has a property called ListId. If the page which hosts the Summary Links Web Part is located in for example SitePages, then the id will point to that list. Once you save the template, this id will come along, and will of course not exist in the new site.

When it comes to the Summary Link Web Part it really don’t need a reference to a list, as it’s storing all the data inside the web part itself. To fix up the template site before saving it I wrote the following PowerShell script.

function FixWebpart($wpm) {
$count = $wpm.WebParts.Count-1
ForEach ($number in 1..$count )
{
$webpart = $wpm.WebParts[$number]
# Check if it's a summary link web part
if( $webpart.PsObject.TypeNames[0] -eq 'Microsoft.SharePoint.Publishing.WebControls.SummaryLinkWebPart' ) {
write-host "Fixing listid - " + $webpart.Title + " : " + $webpart.ID
# Set the id to a blank GUID
$webpart.ListId = [guid]::Parse("00000000-0000-0000-0000-000000000000")
$wpm.SaveChanges($webpart)
}
}
}

#Get a reference to the template site
$web = get-spweb https://intranet.contoso.com/sites/template
$list = $web.Lists.TryGetList("Site Pages")

foreach($item in $list.Items) {
$wpm = $web.GetLimitedWebPartManager($item.Url, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
FixWebpart($wpm)
}

Thursday, March 20, 2014

SharePoint Search Queries Explained - The Series

Want the book? Go get it!

First, I’d like to thank Maximilan Melcher for the inspiration to the simple title of this blog series, and the episode numbering.

For the past year I've written quite a lot of search queries and search query rewrites via query rules in SharePoint 2013 both in customer projects and for presentations. Although there is documentation out there for the gumshoes out there, I though I’d digest it all into a series of blog posts.

Below you will find a list of topics I’m planning to cover. If you have any other suggestions, feel free to drop me a note.

Wednesday, March 12, 2014

Debugging Managed Properties using SharePoint Query Tool v2

The SharePoint Conference 2014 in Las Vegas March 3-6 had many great sessions on working with Display Templates and search. One of the tricky part at times when working with Display Templates and search results is making sure your managed properties have the data you expect, or simply seeing what data is available for an item.

To help with this, Matt King had a post on using the undocumented ManagedProperties managed property to list all available properties for an item.

When using the SharePoint 2013 Query Tool you enter the refinement filter below, which will return all the properties as a long refinement list.

managedproperties(filter=600/0/*)

image

SPC14: Managing Search Relevance in SharePoint 2013 and O365

I had a great time preparing for and presenting this session together with David Hollembaek at the Microsoft SharePoint Conference 2014 in Las Vegas March 3-6.

The session was directed at IT-Pro, as search is more or less about configurations these days and it was a level 300 session. This means we did not cover the basics of Query Rules, but dove into some real life examples on how to use them.

We got some comments afterwards that it was hard to read the demo screen far in the back (where people should have moved up, as there was ample room Winking smile ), but now you can watch the video and see it clear as day. We also appreciate the other feedback we got and the great questions afterwards. If you attended and haven’t evaluated yet, please head over to MySPC and do so.

The rating so far on the session is as follows

Evaluation Count: 52 
Question: Average Score:
The speaker’s presentation style helped me better understand the material. (5 excellent - 1 poor) 4.63
The speaker was knowledgeable about the subject matter. (5 = high to 1 = low) 4.92
The presentation was effective. (5 = high to 1 = low) 4.60
The demo(s) were effective. (5 excellent - 1 poor) 4.65
Overall satisfaction with this session. (5 = high to 1 = low) 4.69
Overall: 4.70

The video and slides can be found at http://channel9.msdn.com/Events/SharePoint-Conference/2014/SPC382

Saturday, March 8, 2014

Search Query Tool v2–released on Codeplex

Having been granted contributor access to the SharePoint 2013 Query Tool project I have together with Maximilian Melcher added some new useful features to the tool over the last couple of months. v2 of the tool was released on Codeplex during my session, “Managing Search Relevance in SharePoint 2013 and O365” at SPC14, as I had previously hinted to at Yammer.

image

The new features are:

  • Rank Detail, implementing ExplainRank in the tool itself
  • Pick Result Source, no need to enter the GUID’s of oob sources
  • Live Monitoring on-premises
  • Anonymous Login
  • Freshness Boost

Head over to https://sp2013searchtool.codeplex.com/ and grab your copy now!

Friday, March 7, 2014

Search discussion at the SharePoint conference 2014 on Channel 9

While at the SharePoint Conference 2014 in Las Vegas this week I did a segment on Channel 9 with Matthew McDermott. It was a lot of fun and head over to http://ow.ly/ukmMz for more information.