Friday, January 22, 2016

Do something after all refiners templates have completed rendering

Elio Struyf is a good friend and did a post today which I have shamelessly copied my post title from. Elio missed an approach on how to run code once all refiners (or other search part) has been rendered, so I figured I’d help him out :-)

Be sure to read Elio’s excellent post before you continue!

Wednesday, January 20, 2016

Find people based on taxonomy id’s

The typical scenario shown and used is where you want to list content relevant to a user based on a property on the content and a property on the user profile. For example the Ask Me About property for a user will by default store the terms as enterprise keywords. This means that if you want to list content with enterprise keywords enabled for the current user you can use a query template like:


What if you want to list all people tagged with taxonomy values from a page?

Now we have the exact opposite scenario.

{|AskMeAbout:{Item.TaxKeyword} will work, as it uses the labels and not the id’s. However {|AskMeAbout:{Item.TaxKeyword.Id} will not work as the AskMeAbout field only has labels and not id’s. If you have terms with the same label in different hierarchies, or labels which can be sub-strings of other labels, then this very quickly breaks.

Is there a solution? Of course!

Here’s the magic you need to know. When you have a user profile property tied to a taxonomy, you will get a crawled property named ows_taxid_SPShPropertyName for SPS- prefixed properties and ows_taxid_PropertyName for other ones, with corresponding managed properties named owstaxIdSPShPropertyName / owstaxIdPropertyName. Just like you get for taxonomy based site columns for content.

Switch the query over to: {|owstaxIdSPShResponsibility:{Item.TaxKeyword.Id} and you’re all set. (SPS-Responsibility is the internal name for the user profile property Ask me about.)


The main difference for taxonomy based user profile properties is that the managed property only contains the id’s, not the labels, but it does include the property with and without the #0 prefix as well as the termset id.


Note: The user profile property has to be visible to everyone and marked as indexeable for it show in search.

How I watch movies without disturbing my wife and kid


I’ve been known to like action movies, and in particular what we in Norwegian call “gla’vold” – think Tarantino style, or even Toxing Avenger (can’t discriminate on the genre and quality). These movies work best with a certain volume turned up. As I live in an apartment, it’s out of the question to crank up the volume unless I’m home by myself, because my wife and kid would be seriously annoyed. For years now this has declined my consumption of movies, and when I have self-time I need to choose between coding on some pet project or watch a movie.

Disclaimer: I'm no audiophile, and sound over bluetooth will never be the same quality as if you use a cable since audio is lossy compressed. But who cares when we talk about gadgets :)

Not any more!

A while ago I bought a pair of Nokia Purity BH-940 by Monster bluetooth headphones based on a review by Scott Hanselman. I mainly bought them to act as office headphones serving music and also to by used for Skype calls. As they are noice cancel headphones, they also work for plane rides. Except the review does not mention that bluetooth has a flaw when it comes to audio sound on calls when you use the microphone. The quality is plain and simple crap. 

This has nothing to do with the BH-940’s, but the bluetooth protocol. Listening to music only with my Surface 3 Pro was no problem, but calls not so much. I have now replaced the BH-940’s for Bose QC20’s (earbuds) which I won and hence free, and also a cheap USB headset for talks. Which means the BH-940’s has been sitting in a cupboard for a while. Not sure I would recommend the BH-940's myself, but I happened to have them handy.

One evening surfing the net I came accross the Tosblue X from Telme2 ($69) which can take an optical signal via toslink or a 3.5mm mini-jack, and send it out over bluetooth. I googled a bit on reviews and placed my order.

With the Tosblue X in place my current setup is now optical audio out from my Samsung Smart TV, into a toslink splitter, where one goes to my soundbar/subwoofer and the other to the Tosblue X.

Pairing was super simple, and delay was not noticable to me, so no need to worry about lip sync. I’ve tried a couple of movies now via Netflix and the audio is back! Also tried them listening to a slalom sports broadcast, and the audio detail via the headphones was so much better than the soundbar. Suddenly I picked up all turns and snowsounds as well as some distant chainsaw.

The problem now is that I want to wear them any time I watch TV – which does not sit well with other people in the same room :)

So if you're in need of audio at night without cables, this solution might be a fit.

Tuesday, January 19, 2016

Creating crawl rules for SharePoint search with persistant cookies using PowerShell


There are numerous posts out there on how to programatically create a cookie based crawl rule which will first login at a specific URL, and then use the cookies recived when crawling the content source. This is however the first one on how to do a persistant one.

Here’s a brief sample:

$ssa = Get-SPEnterpriseSearchServiceApplication
#Create rule
$rule = New-SPEnterpriseSearchCrawlRule -SearchApplication $ssa -Path 'http://**' -Type InclusionRule -FollowComplexUrls $true -AuthenticationType CookieRuleAccess
#Add cookie information
$authUrl = ""
$rule.SetCredentials([Microsoft.Office.Server.Search.Administration.CrawlRuleAuthenticationType]::CookieRuleAccess,"pzl", $authUrl)

The above code will before each crawl call the url from $authUrl to get the cookie. The cookie added above with “Pzl” is just a dummy cookie for making the command work.

Wednesday, January 13, 2016

Getting diacrits to work with thesaurus in SharePoint search

When you live in Europe you tend to decorate the English a-z letters every so often. If you don’t know what I mean here’s some examples:

ö å ï é à

The important part when you create your thesaurus csv file as mention on TechNet is to save this file in UTF-8 format for it to work. And also do it without BOM/Ssgnature to be super sure.

In Notepad++ you find the setting under Encoding


In Visual Studio you pick Save As, then click the arrow on the Save button, pick Save with Encoding…and pick Unicode (UTF-8 without signature) – Codepage 65001 as your encoding.



The same goes for any other character set as well – stick with UTF-8 without signature.

Happy synonyming, and thanks for Elio Struyf for asking me this question!

Tuesday, January 12, 2016

How to filter out BCS top level entities in search


When indexing BCS sources in SharePoint you get two extra top level entries which are not actual data rows. These rows are also searchable by anyone and will appear as noise in your search results unless you filter them away – typically a problem when doing wildcard searches.


When you index BCS entitiy models. SharePoint adds a hidden managed property named entityname to the search schema. This managed property contains the name of the BCS entity being indexed, and is not set for the toplevel BCS items. Hence you can add a filter of entityname:modelname to make sure you filter on exactly what you want, instead of filtering on contentsource.