Wednesday, November 19, 2014

Black Market GUID’s

image

I’m currently sitting in the speaker room for SharePoint Connect 2014 in Amsterdam and somehow we got into talking about GUID’s. If you scour the interwebs you will find numerous sites offering to generate a unique GUID for you. There is even fraud sites where you can register and reserve GUID’s.

But what I did learn is that if you really want a truly unique GUID, one to keep and use all to yourself, one which will trump any other equal GUID held by someone else, then you have to go to the BLACK MARKET.

In every major city there are people dealing with black market GUID’s. They are truly unique and apparently of great quality. They have even survived the recent economic crises without so much as a dent or lost bit. I was lucky enough to buy one for my last euro’s second hand at the conference, and if everything goes my way I was told I will get the number for a local dealer in Oslo -  so as to scratch my daily needs for fresh GUID’s.

Unfortunately I cannot reveal the identity of the person selling it to me – but seems these black market dealers show up at larger conferences to hook more consumers of GUID’s.

Tuesday, November 18, 2014

Office Video is Live

Office Video just went live today November 11th, 2014. First they launched the Delve portal, now the Office 365 Video portal. Both driven by search. What’s next?

Getting-Started-1.jpg

I have had the fortune to test out the preview and have with my colleague Andreas written a guide to get you started planning this new awesome feature. Head over to Getting started with Office 365 Video to read all about it and also check out Office 365 Video Explained for some good insight into the platform.

Also check the official blog post for an introduction.

Tuesday, November 11, 2014

Tired of getting AllItems.aspx hits in your results?

If you append -contentclass:STS_List_* to your query template, they will all be excluded. In effect all list landing pages will be removed including:

  • AllItems.aspx
  • AllPages.aspx
  • AllPosts.aspx
  • AllCategories.aspx
  • Calendar.aspx
  • Overview.aspx

If you want to find all types excluded use the SharePoint 2013 Query Tool from Codeplex and issue the following query.

  • Row limit: 100 (or some high number)
  • Query Text: contentclass:STS_List_*
  • Collapse Spec: contentclass

The collapse specification ensures you only get one result per unique value.

Monday, November 10, 2014

How to: Make sure User Profile properties are free/full-text searchable

You get a requirement to add a new property called FavoriteColor to the user profile application, which you want searchable on the people search page. You create it, you fill it in, you wait for a crawl so that the crawled property People:FavoriteColor shows up, you create a new managed property named FavoriteColor, map your crawled property to it, fire off a full crawl for people, head over to people search page and type your favorite color.

Nothing shows!

However, if you type FavoriteColor:color, you get results.

I’ve gotten this question four or five times now, so thought I’d write it up.

The solution is as hard as it is easy. When you create a new managed property, it is by default added to the Default full-text index, not the PeopleIdx full-text index. The full text-index is what is used when you perform a free text query (as apposed to a property query). When querying for people you have to make sure your managed property is in the PeopleIdx.

On the managed property settings page, click the  Advanced Searchable Settings button, and pick PeopleIdx from the dropdown.

image

Next up perform a new full-crawl of the UPA, and it should all work!

If you are curious what the FullTextIndex1/2/3 are, just stay away from them and don’t give it a second thought. They could in theory be useful, but when moving from FAST Search for SharePoint to 2013, some query logic was forgotten, so they are all but useless (known issue by the product team, and a ticket has been filed and archived). I might do a write up on that later – but not too many would be interested in it.

Wednesday, November 5, 2014

You should use exponential notation when writing XRANK queries


I have previously mentioned a problem using decimal numbers on XRANK statements in my Freshness Boost post. The problem is that the decimal separator used differs on your locale.
For example in Norwegian the character used is , (comma) while in English the character used is . (punctuation). The issue arises when a query rules is written using one locale, and being used on a query in a different locale.
Say I have a query rule with the following XRANK statement where I use . as the decimal separator
{searchterms} XRANK(cb=0.5) title:test
If a user has their SharePoint locale or browser settings set to Norwegian, then the query will fail, giving you an error message that search didn’t understand the query. The reason for the error is that the query framework will use .Net to parse the number with Double.Parse(), and this function is culture sensitive when parsing, and the culture used is based on the users locale settings.

The solution, as I have implemented in the Freshness Boost Generator, is to instead use exponential notation when writing the numbers. This means 0.5 is written as 5E-1 and 0.25 would be 25E-2. The number behind the E character is the number of decimal places to move to the left. This ensures that parsing the number always work, regardless of the locale used.
Rewriting the above query you end up with
{searchterms} XRANK(cb=5E-1) title:test
As a conclusion you should always use exponential notation when writing decimal numbers in an XRANK statement to ensure it will work across different locale settings.

Friday, October 31, 2014

Caution: If you have scripted your Search Service Application (eg. AutoSPInstaller) in SharePoint 2013 your search based pages could end up like this

Important!
If you have scripted your SSA, make sure the farm account has db_owner on your search db’s, or you may find yourself in a lot of trouble one day!

search-based-intranet

Wednesday, October 29, 2014

Retrieve Search Center URL from a SharePoint page

I have previously written about how you via REST can retrieve the Search Center URL for a particular SharePoint site.

If you are already on a page which has a search web part on it, you can get the same value from the page itself with the following command:

Srch.ScriptApplicationManager.get_current().states['searchCenterUrl']


To be clear; when a search web part exist on the page search Search.ClientControls.js is loaded and makes the Srch namespace available.

Tuesday, October 28, 2014

How to change the number of decimal places on a number column using CSOM

Got a challenge for a one liner by the strongest man in SharePoint (@tarjeieo) to do this using CSOM as with with SSOM you can set the DisplayFormat property of the field. Using CSOM, this property is not available.

A one liner would be ugly, but the way to accomplish this is to modify the SchemaXml of the field, so you could encapsulate the code below in a function.

Using XML manipulation I ended up with this.

ClientContext clientContext = new ClientContext("https://site/);
Web web = clientContext.Web;
Field field = web.Fields.GetByTitle("DummyNum"); // Field to modify
clientContext.Load(field);
clientContext.ExecuteQuery();
XmlDocument doc = new XmlDocument();
doc.LoadXml(field.SchemaXml);
XmlNode fieldNode = doc.SelectSingleNode("Field");
XmlAttribute decimalAttribute = fieldNode.Attributes["Decimals"];
if (decimalAttribute == null)
{
decimalAttribute = doc.CreateAttribute("Decimals");
fieldNode.Attributes.Append(decimalAttribute);
}
decimalAttribute.Value = "4";
field.SchemaXml = doc.OuterXml;
field.UpdateAndPushChanges(true);
clientContext.ExecuteQuery();

Monday, October 27, 2014

Caution when creating global query rules

If you create query rules which modify the query on your tenant or SSA level, then you are effectively killing off any such rules on the site collection level.

The below screen shot is taken running a query in the query rule tester. You see the first rule for blog’s is triggered. This rule has been set to stop, as it modifies the query and I want no more processing. You can see the stop flag actually works works, as the next rule is grayed out.

But then a rule from the SSA is showing in blue again, not honoring the Stop flag from the site collection. Ideally it should have been grayed out as well. The reason for this is that if you have more than one rule which modifies your query, then neither is executed (even though the test interface shows so).

image

In my case the SSA rule is adding an exclusion rule for all search results on Local SharePoint Results. The way to solve this is to create a custom result source on the SSA (or any other level where you need it), add the exclude filter here, and set this source as the default source instead.

Or if the results excluded shouldn’t be used anywhere, mark the site not to be indexed instead.

Tuesday, October 21, 2014

I'm doing an extra talk at SharePoint Connect 2014 - Social Refiners is the game!

Back in May I posted about SharePoint Connect 2014 letting me in to do a talk about Search Queries Explained. A vacant spot just opened up and I was asked if I could do one more, and I jumped at the chance.

I've decided to do a developer talk on how to create "Social" refiners on your search result pages.

The session will involve Display Templates and JavaScript with some FQL sprinkled in. I will show how to create my trusty old Department refiner for content and a refiner for content close to you, both based on your organization, who you follow and who you interact with from the Office Graph.

Hopefully you will pick up a trick or two and get some ideas for your next project - and if you are near sighted, sit up front as it's all code :)