Joel's SharePoint Architect Blog

SharePoint 2013 Training, Architecture, Administration and Development

Subscribe Subscribe  View Joel Jeffery's profile on LinkedIn
joelblogs.co.uk | joelj.co.uk | joeljeffery.co.uk | jfdiphoenix.co.uk

Posts Tagged ‘Search’

A while ago, a student of mine asked if it was possible to use the taxonomic alternative labels from the Managed Metadata Service as thesaurus items in SharePoint Server Search.

There’s no built-in way to do this, but it is possible to generate the required Xml with a little PowerShell.

The Concept

The Term Store contains Term Group, which content Term Sets, which in turn contain nested Terms. Each Term can have (optional) synonyms called Labels.

If we find all the Terms with Labels, we can write them out in the correct format as a chunk of Xml, and pipe it into a thesaurus file.

Thesaurus files for SharePoint Server Search are kept under the file path:

%ProgramFiles%\Microsoft Office Servers\14.0\Data\Office Server\Applications\GUID-query-0\Config

A sample thesaurus file is shown below:

<XML ID="Microsoft Search Thesaurus">
    <thesaurus xmlns="x-schema:tsSchema.xml">
        <diacritics_sensitive>0</diacritics_sensitive>
        <expansion>
            <sub>Internet Explorer</sub>
            <sub>IE</sub>
            <sub>IE8</sub>
        </expansion>
        <replacement>
            <pat>NT5</pat>
            <pat>W2K</pat>
            <sub>Windows 2000</sub>
        </replacement>
    </thesaurus>
</XML>

You can see the rationale for how this file works on and how to manage thesaurus files at TechNet.

The Script

The script below shows the principle. It iterates over the Terms in each Term Store and finds their Labels. Where the Label is not the same as the name of the Term itself, it represents a synonym and we add it to the Xml.

function Extract-SPThesaurusFromTermLabels
{
  param([string] $webUrl);
  $ts = Get-SPTaxonomySession -Site $webUrl;
  Write-Output "<XML ID='Microsoft Search Thesaurus'>"; 
  Write-Output "<thesaurus xmlns='x-schema:tsSchema.xml'>"; 
  $ts.TermStores | 
  % { $_.Groups | 
    % { $_.TermSets | 
      % { $_.Terms | 
        % { $_.Labels | 
          ? {$_.Term.Name -ne $_.Value} |
          % { 
            Write-Output ("<expansion><sub>" + $_.Term.Name + 
              "</sub><sub>" + $_.Value + "</sub><expansion>");
          } 
        } 
      } 
    } 
  }; 
  Write-Output "</thesaurus>"; 
  Write-Output "</XML>";
}

You can then pipe the output of this command to an Xml file, and optionally use this in the place of your existing Thesaurus file with something like this:

Extract-SPThesaurusFromTermLabels http://sharepoint > tsLANG.xml

As always, please back up your original Thesaurus files and check the output of this before you use it! Smile

Technorati Tags: PowerShell, Search, SharePoint, SharePoint 2010, SharePoint Administration, SharePoint Administrator

I’m a massive fan of the new “Bing” search service from Microsoft newly release this month. It seems we now have a suitable competitor to Google’s offerings.

Microsoft Bing Search

Firstly, web search seems to have come of age. The results feel a lot more relevant and snappy than previous incarnations. However, the big “wow” for me is the new mapping tool – a gestalt based on Multimap and Virtual Earth. If you want to start using these on your own web pages, it’s almost trivially easy. To embed a Bing map on your web page, simply:

  1. Head over to www.bing.com and click on Maps
  2. Key in the location and navigate to your desired map point
    Bing Map View
  3. Optionally, right click and set the red circle over your target
  4. Hit the “link” button in the top-right corner of the map
    Link or Embed a Bing Map
  5. If you’re happy just linking to the map, copy and paste the Url and you’re done. If you actually want to embed the Bing map in your web page, you need to accept their terms and conditions
    Bing Map Link Details
  6. Once you’ve accepted the T’s and C’s you can simply copy and paste the DIV tag into you web page. If you want to change the size of the map, you can customise the view on a summary screen.

For some, presumably licensing, reason, Microsoft won’t let you embed bird’s eye views, which restricts you to choosing Map or Aerial views. If you can live with this restriction – and for free, I certainly can – then you’re good to go and enjoy your new map.

Happy embedding!

Technorati Tags: Bing, Google Maps, Maps, Search, Virtual Earth