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.