Search, SharePoint, Technical

Interactive Ratings in Search Results

I found a great post that saved me a TON of time when working on a solution to bring in interactive ratings of documents to a search results page. Thank you Eugene! (Not sure what your last name is…sorry)

I’m adding to it here because I ran into an issue where the code wasn’t able to pull the client context so was throwing null object errors. This happened after publishing the search results page and was due to sp.js not being loaded. Luckily I’ve run into this before so the fix was quick. I changed his SearchRatingViewModel function code from:


//invoke update whenever rating value changes
vm.rating.subscribe(function () {
loadScript('reputation.js', function() {
vm.updateRating();
});
});

To:

//invoke update whenever rating value changes
vm.rating.subscribe(function () {
loadScript('sp.js', function () {
loadScript('reputation.js', function() {
vm.updateRating();
});
});
});

So the sp.js library gets loaded, which fixed the null object errors.


Search, SharePoint, Technical

To-Do When Adding Managed Property Mapping to Hover Panel

I often have a request to display custom data in a search hover panel in SharePoint 2013. No big deal…pop open the IDE of your choice (BTW, if you have a favorite IDE other than VS or WebStorm, leave a comment) and create a new display template, add your managed property mapping using the managed property field name, associate the new hover panel with the search result, go get a beer. At least that’s what I normally do. J

Except it doesn’t work and you bang your head against the desk trying to figure out why. It could be because you forgot to also add the managed property mapping to the “parent” display template that calls your new hover panel display template. This is required, and often missed. I can’t count how many times I’ve forgotten that step so feel in good company if you’re reading this and in that situation.

Now go get a beer.

Search, SharePoint, Technical

Format Date on Search Results

In building a custom display template for search results I found myself in an interesting scenario. The display template needed to make a REST call back into SharePoint 2013 to get additional info for display and one of the properties in that result was a date field. When making a call through the API like this, SharePoint will return the date in ISO format (i.e. YYYY-MM-DDTHH:mm:ss.sssZ.) Since this REST call is done client side through JavaScript, my default inclination was to format the date using

var myDate = isoStringReturnedFromRESTCall;
var displayDate = new Date(myDate);

Then either pull out what I needed from displayDate, or format it appropriately when creating the Date object. All is good there, except I needed to support IE8. Turns out IE8 doesn’t support creating Date objects from an ISO date format, it throws an “Invalid Date” error. Crap.

To get around this, I ended up creating the date object from Date.UTC after splitting out the appropriate components from the ISO date string. Here’s what that looks like:

var updateDateStr = isoStringReturnedFromRESTCall;
var updateDateArray = updateDateStr.split(‘T’);
var dateArray = updateDateArray[0].split(‘-‘);
var timeArray = updateDateArray[1].split(‘:’);
var updateDate = new Date(Date.UTC(dateArray[0], dateArray[1]-1, dateArray[2], timeArray[0], timeArray[1], 00));

From there I could interact with updateDate as a normal Date object.

Search, SharePoint, Technical

Duplicate Key Error when Editing a Content Search Web Part

When developing custom display templates for your CSWPs, be careful when setting the property value for ManagedPropertyMapping. This property is used to tell the template how to map managed properties to properties within the template, so you can pull them in and display the property. If you add the same property more than once, you won’t be able to edit the web part properties of CSWPs in the site collection where the display template is located. You will get this error in ULS:

System.ArgumentException: An item with the same key has already been added.    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)     at Microsoft.Office.Server.Search.WebControls.ResultScriptWebPart.ParsePropertyMappingsString(String mappings)     at Microsoft.Office.Server.Search.WebControls.ContentBySearchToolPart.get_MaxSlots()     at Microsoft.Office.Server.Search.WebControls.ContentBySearchToolPart.CreatePropertySlotControls()     at Microsoft.Office.Server.Search.WebControls.ContentBySearchToolPart.CreatePropertyMappingsSectionControls()     at Microsoft.Office.Server.Search.WebControls.ContentBySearchToolPart.CreateSections()     at Microsoft.Office.Server.Search.WebControls.ContentBySearchToolPart.CreateChildControls()     at System.Web.UI.Control.EnsureChildControls()     at Microsoft.Office.Server.Search.WebControls.ContentBySearchToolPart.OnLoad(EventArgs e)     at System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

When I say to not add the same property more than once, I mean with the same property name as specified within the template. Not the same managed property. In other words, it’s ok to map the same managed property to more than one template property:

<mso:ManagedPropertyMapping msdt:dt=”string”>’Line 1′{Line 1}:’Title’, ‘Line 2′{Line 2}:’Title'</mso:ManagedPropertyMapping>

But you can’t create two template properties with the same name, like this:

<mso:ManagedPropertyMapping msdt:dt=”string”>’Title’:’Title’, ‘Title’:’Path'</mso:ManagedPropertyMapping>

Those were simple examples, but as you add more and more properties, you could lose track. Don’t.

Search, SharePoint, Technical

The Filtering Process has been Terminated

On a SharePoint 2013 farm we recently had search throw errors consistently being unable to crawl and index content. Looking into the crawl logs, I saw the error “The filtering process has been terminated”. Doing a quick search on Bing led me to this post for SharePoint 2010. It is in German, but if you translate it the gist of it is to make sure the service account has full control to the Temp directory. So I went in to all of my search servers and granted full control on the c:temp directory to wss_wpg as well as wss_admin_wpg. I think only the former group is necessary, however, and full control is probably a bit much. Write permission should be sufficient.

After making that change and restarting the search services on all servers, I was able to get the farm to perform a successful crawl.

I don’t normally post content that others already cover, but I thought this was worthy since I didn’t see anyone else run into this with 2013. I also thought it important to point out the requirement to restart the services, as I found some forum posts that didn’t state that need.

Search, SharePoint, Technical

On-Premise SharePoint 2013 Edition Comparison–Search

Pulling the table below from TechNet, the difference between Standard and Enterprise search in SharePoint 2013 is really only:

  • Content Search Web Part
  • Custom Entity Extraction
  • Extensible Content Processing
  • Advanced actions on Query Rules
  • Video Search

The differences from Foundation to Standard are too many to list separately so I’ll let the table do the talking.

Search features SharePoint Foundation SharePoint Server 2013—Standard Edition SharePoint Server 2013—Enterprise Edition
Advanced Content Processing Yes Yes Yes
Content Search Web Part No No Yes
Continuous crawl Yes Yes Yes
Custom entity extraction No No Yes
Deep links No Yes Yes
Event-based relevancy No Yes Yes
Expertise Search Yes Yes Yes
Extensible content processing No No Yes
Graphical refiners No Yes Yes
Hybrid search Yes Yes Yes
Managed navigation No Yes Yes
On-premises search index N/A N/A N/A
Phonetic name matching Yes Yes Yes
Query rules—Add promoted results No Yes Yes
Query rules—advanced actions No No Yes
Query spelling correction Yes Yes Yes
Query suggestions No Yes Yes
Query throttling No Yes Yes
Quick preview Yes Yes Yes
Recommendations No Yes Yes
Refiners Yes Yes Yes
RESTful Query API/Query OM Yes Yes Yes
Result sources Yes Yes Yes
Search connector framework No No No
Search results sorting Yes Yes Yes
Search vertical: “Conversations” No Yes Yes
Search vertical: “People” No Yes Yes
Search vertical: “Video” No No Yes
Tunable Relevancy No No No