Thursday, November 29, 2012

FS4SP Logger v4 release

I’ve been so lucky to get Alexey Kozhemiakin to include some improvements on the rank log of this tool.

In addition to better formatting of the rank log and splitting it into more detailed parts showing for example which managed properties you got a hit in, the tool now also provides the raw ranklog information as well.

v4 is available for download at http://fs4splogger.codeplex.com/

image

Saturday, November 3, 2012

People Search and Extensibility in SharePoint 2013

If you are attending SPC12 and haven’t booked your session slot for Tuesday at 1:45PM yet, you might want to walk yourself over to #SPC191 and attend the session I’m presenting together with Sana Khan from Microsoft. [Add it to MySPC]

I will also be at the O'Reilly booth Monday at 3:15pm-3:45pm if you want to drop by for a chat about FAST Search for SharePoint 2010 or search in general.

Monday, September 24, 2012

What I’ve been up to lately

I haven’t been blogging for a while now and you might wonder why I’m not flooding my blog with 2013 content. Well, seems there is a good reason for it.
WP_000191I had my summer vacation all of July, and had promised myself not to do any extra curricular work. I kept that promise more or less even though I did post on the hardware requirements for 2013 dev. And that was just about how much 2013 work I did during the summer. But I did pick chanterelles with my son, which he’s quite good at even though it was his first time.

Wednesday, July 18, 2012

Hardware requirements - Developing for SharePoint 2013

If you are developing on-premise solutions where you deploy good old WSP packages to SharePoint, this is a post for you. If you are developing SharePoint Apps, you can get away with just about any setup (overly simplified statement).

The minimum recommended requirements for SharePoint development just got upped. TechNet recommends a minimum of 8GB ram and 4 cores. This is double of what was recommended for SharePoint 2010. My own tests show that you can perfectly well develop with 2 cores and 8GB ram on a single VM with DC, SQL, SharePoint 2013 and Visual Studio installed….if you have an SSD drive. You can also go down on ram to about 6GB depending on which features you use, but I think 8GB is acceptable.

Thursday, June 28, 2012

How-to: Get individual items from a delimited field using FS4SP

Thought I’d share a small useful program I often use when indexing data into FAST Search for SharePoint. The issue is that you get data back from some system where the values are concatenated into one field. For example:

user1,user2,user3

But you want to treat each value as a separate one. In FS4SP you have to delimit the values with the unicode character U+2029. The task is simple; replace the exiting delimiter character with this special one.
If you get the data via BCS you might can change the SQL for a view to do this directly(haven’t tested), or you can employ a custom extensibility program. If doing the latter here’s the code:
using System;
using System.Xml;

namespace mAdcOW.MultiValue
{
  class Program
  {
    static int Main(string[] args)
    {
      try
      {
        XmlDocument doc = new XmlDocument();
        doc.Load(args[0]);
        foreach (XmlNode node in doc.SelectNodes("Document/CrawledProperty[@varType='31']"))
        {
          // here you can add replacement for other characters
          // as well besides comma
          node.InnerText = node.InnerText.Replace(',', '\u2029');
        }
        doc.Save(args[1]);

      }
      catch (Exception e)
      {
        Console.WriteLine("Failed: " + e.Message + "/" + e.StackTrace);
        return 1;
      }
      return 0;
    }
  }
}

Thursday, June 21, 2012

Why more people should blog (or My bad day hunting down an error with FS4SP)

Today has been one of those days where you feel you haven’t done anything productive, thinking you have tried all tricks in the book to fix some weird error to no avail.

And just now the solution came to me after spending some time with my family and letting my brain work it’s magic without my focus. And I’m just about 100% sure it will work when I test it tomorrow morning.

The short version

Always use mklink /J when moving a folder from within your FAST installation to another volume (and blog about any error you encounter for others to read).

Wednesday, June 13, 2012

Adding prefix logic to the ribbon search box

A common scenario when upgrading from SharePoint search to FAST Search for SharePoint is that you want to run the new search solution side by side with the old until you are comfortable switching.
image
One solution is having two search centers which targets the old and the new index. In my experience end-users find it cumbersome to navigate to the new search center in order to do testing because they want to use the search box in the ribbon as the entry point to the search center. The chosen solution for this post is to allow users to enter a prefix character in the search box to opt-in to use the new search engine.

Saturday, June 9, 2012

Using PowerShell in a .NET installer for a SharePoint App

powershell_2This is not a post about how to invoke PowerShell from within .NET or why you should do it. It is a post about second guessing why you write code the way you do.

At Puzzlepart we have created a time tracking application and we have an .exe installer to provision a site, and create all lists and content types needed. Some weeks ago we decided to have the installer deploy the WSP as well, and not only to post-deploy work.

Friday, May 4, 2012

Displaying data with <%# %>, OnDataItemBound or use OnDataBinding in ASP.net?

This has been on my mind for years and I have seen both and used both in different projects the last 10 years. But which is better or preferred?

As an example consider a ListView which will bind to a poco called Employee which has properties Name and EmployedSince. The ListView will display the name of the employee as well as how long the user has been employed in years.

public class Employee
{
    public string Name { get; set; }
    public DateTime EmployedSince { get; set; }
}

Monday, April 16, 2012

When numbers are important to your organization

I was contacted recently by a financial organization which had issues with the sorting of their search results using FAST Search Server 2010 for SharePoint. The issue was that when including year numbers in the search query, they were not given any relevance while ranking the search results.

A typical query could be income statement 2010, but the top results returned documents for 2006.

Clearly the year number 2010 was being excluded from ranking the results, and terms excluded by rank indicate stop word threshold issues.

Friday, March 30, 2012

Won the antlers trophy at Arctic SharePoint Challenge!

antlers2

Last week saw the 2nd incarnation of the Arctic SharePoint Challenge –ASPC2012. ASPC is a community event for SharePointers by SharePointers; in essence a three day team based code camp with competitions and lightning talks throughout the event. Around 50 people attended spread over 12 teams.

The goal of the competition is to create cool SharePoint solutions for the fictitious company Lynx Inc. where you can show off all your hard earned SharePoint skills. Along the way teams earn badges in numerous categories, where each badge earns you points as well. At the end of each day a “stage winner” is awarded, which gives lots and lots of points.

After the three days, the three teams with the most points enter the finals, and all the attendees of the event cast a vote to pick the winner. Sounds simple enough? Well, it is if you’re as productive as we were during the event :D

My team did not have time to prepare before the event, but we had one idea, we wanted to hook the Xbox Kinect up to SharePoint. And so we did. Check out our excellent solutions like Lynx InCare - Your workplace health tracker and Lynx Inc FacePalm Detection Agent.

We also delivered other solutions not using the Kinect, such as a “Sexual Harassment Early Warning System” and “Handbook provisioning from Word to SharePoint”. The latter was submitted by me to large protests from my team members as it actually has 100% business value and no silliness to it.

imageTo cut the story short. Among our seven submissions and two lightning talks we managed to rake in 16 badges and 2233 points in the end to bring home the trophy, now hanging proudly in our offices at Puzzlepart.

The event was great fun with lots of cool coding, lots of socializing and lots good food/drinks in the evenings. Ideas for next year are already churning in my head!

And a tip at the end: If you forget your belt when travelling, be sure to keep at TP cable handy in your computer bag.

Thursday, March 29, 2012

The book is out!

If you haven’t already seen my tweets or noticed yourself, “Working with Microsoft FAST Search Server 2010 for SharePoint” is ready for sales in print edition at both Amazon and O’Reilly web sites. The e-book should arrive shortly as well.

It’s been fun and a lot of work creating the book, but together with my co-authors Marcus Johansson and Robert Piddocke we managed to complete it.
I hope and think that everyone should find something interesting and useful in it and I’d love to get your comments and thoughts on it.



I would also like to thank my employer Puzzlepart for supporting my writing and allowing me time during the day for parts of the writing. Very valuable indeed!

Friday, March 9, 2012

How to: Make folder hits appear at the end of your search results

imagePaul Olenick tweeted me a question on how to get folder hits to appear at the end of the search results using FAST Search for SharePoint.

If we are talking about folders from file shares this is not too hard. If we refer to my post about Taking promotions/demotions one step further we can accomplish this by adding negative promotion using XRANK.

Monday, February 20, 2012

Finding the week number from a date–ISO 8601

I previously wrote about how to find the first day or date given a week number and how to get that working correctly.

Going the other way is in theory easier as you can use functions from .Net itself.

public static int GetWeekNumber(this DateTime date)
{
    var currentCulture = CultureInfo.CurrentCulture;
    return currentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
}

Except there is a bug in .Net which will return the wrong week for some boundary dates around the end of December and the beginning of January.

The fix is equal to that of my previous post, use the Thursday of the week of your date and it will work.

public static int GetWeekNumber(this DateTime date)
{
    int daysToAdd = date.DayOfWeek != DayOfWeek.Sunday ? DayOfWeek.Thursday - date.DayOfWeek : (int)DayOfWeek.Thursday - 7;
    date = date.AddDays(daysToAdd);
    var currentCulture = CultureInfo.CurrentCulture;
    return currentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
}

Monday, January 30, 2012

Finding the first day of a week–ISO 8601

[See http://techmikael.blogspot.com/2012/02/finding-week-number-from-dateiso-8601.html on how to get the correct week number from a date]

I’m working on an application where we work with week numbers and of course there was an error in getting everything to work correct with week numbers. For a specific week I want to get the Monday of that week. With the ISO 8601 standard a week starts on a Monday and ends on a Sunday, and I’m dealing with a calendar which states that week 1 = the first week with 4 full days.

Our current code was not working, and checking on StackOverflow I found a couple of samples in order to fix this:
http://stackoverflow.com/questions/3854429/in-net-knowing-the-week-number-how-can-i-get-the-weekdays-date
http://stackoverflow.com/questions/5377851/get-date-range-by-week-number-c-sharp
http://stackoverflow.com/questions/662379/calculate-date-from-week-number

The flaw in these solutions is that they all base the week calculation on the first Monday of the year. Reading up on ISO 8601 at Wikipedia the solution is simple:
The week number can be described by counting the Thursdays: week 12 contains the 12th Thursday of the year.
Instead of basing the code on a Monday, use Thursday and all boundary conditions with week 1, 52 and 53 are resolved. Then subtract 3 days at the end to get the Monday.

The following code works for all boundary conditions which the previous code samples fail at:

public static DateTime FirstDateOfWeek(int year, int weekOfYear)
{
    DateTime jan1 = new DateTime(year, 1, 1);
    int daysOffset = DayOfWeek.Thursday - jan1.DayOfWeek;

    DateTime firstThursday = jan1.AddDays(daysOffset);
    var cal = CultureInfo.CurrentCulture.Calendar;
    int firstWeek = cal.GetWeekOfYear(firstThursday, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

    var weekNum = weekOfYear;
    if (firstWeek <= 1)
    {
        weekNum -= 1;
    }
    var result = firstThursday.AddDays(weekNum * 7);
    return result.AddDays(-3);
}

Friday, January 27, 2012

How to do Visual Best Bets for built-in SharePoint Search

Marcus Johansson did a post about the use of Best Bets this morning which inspired me to write this post. Read his post for more thoughts around the use of best bets.

Visual Best Bets is a feature of FAST Search for SharePoint which lets you point to a file with html content to be displayed above your search results. For example an image, silverlight or flash content can be used to graphically enhance what is linked to the keyword term. The Visual Web Part uses an iframe to accomplish this and loads up your content inside the iframe. This is useful as you can easily edit the html file at will.

But why go the extra mile for a separate file, or opt in for FS4SP for this feature? The Best Bet web part support the showing of keywords and keyword definitions. Keyword definitions are formatted as html. And a definition with html formatting is in effect a Visual Best Bet. (If you have more than one Visual Best Bet you want to assign to the keyword you would have to add them all to the same html for this to work.)