1

I recently added a thesaurus to our search app. It works great when searching Everything. However, it doesn't work when doing a People search.

For example, one thesaurus entry is HR,Human Resources. When I do an Everything search, multiple HR documents show up in the results, that didn't before importing the thesaurus. However, our HR employees won't show up in the People search. They do show up if I search for Human Resources, so I know that the field is being searched.

Has anyone had this problem before? I've Googled the issue, and can't seem to find anything similar. Any insight would be greatly appreciated!

  • Did you ever find an answer as we have the same issue. – Matt Nov 21 '16 at 11:02
  • @Matt, unfortunately not. Sorry! – Kaylee Chatham Nov 22 '16 at 20:42
  • I've written some powershell to enumerate everyones properties check if any match a list of aliases then add the aliases to a new property that is in the index. It's a faf but at least now my users can search for HR instead. – Matt Nov 23 '16 at 15:25
1

I worked around the issue with this PowerShell, had to create a new property in the UPS and index it in search but at least you can now search for HR. I also found if you add them to the Thesaurus separately the Hit Highlighting works too.

#Setup the Thesarus Dictionary
$PeopleThesaurus = @{}
$PeopleThesaurus.Add('Human Resources',@("HR"))
$PeopleThesaurus.Add('Business Travel',@("Travel Team", "Travel Department"))



#Profile Attribute Ignore List (Warning, case sensitive)
#$IgnoreList = @("Department","Team","SPS-JobTitle","Title")
$IgnoreList = @()

#UPS People Thesaurus Attribute
$ThesaurusAttribute = 'PeopleThesaurus'

#Get the My Site URL Replace the <MySites URL with your url
$siteUrl = "http://me/"

#Get the Site Context
$site = Get-SPSite $siteUrl
$servcontext = Get-SPServiceContext $site

#Initiate the Profile Manager and get the user profiles
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($servcontext)
$profiles = $profileManager.GetEnumerator()

#Initiate the Config manager to get all the profile properties
$upConfigManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($servcontext);

#Attribute to test if Employee exists
$employeeIDAttribute = "PreferredName"

# Loop through all user profiles.
foreach ($uProfile in $profiles)
{
  # Make sure there is some value in the employee ID property
  if ($uProfile[$employeeIDAttribute] -ne '') {

    #Set the profile commit flag so we don't save unchanged profiles
    $save = $false

    #Get the users Thesaurus Attribute
    $PersonThesaurus = $uProfile[$ThesaurusAttribute]

    #If they already have items in the Thesaurus set save to true and clear it (Removes stale entries, will rebuild later)
    if($PersonThesaurus.Count -gt 0) {
        $save = $true
        $PersonThesaurus.Clear()
    }

    #Create an array to store the dictionary keys for the user
    $personDictionary = @()

    #Loop all UPS attributes and look for Thesaurus entries
    foreach($upConfigManagerProperty in $upConfigManager.GetProperties()) 
    {
      if($uProfile[$upConfigManagerProperty.Name] -and 
         !$IgnoreList.Contains($upConfigManagerProperty.Name) -and
         $upConfigManagerProperty.Name -ne $ThesaurusAttribute -and
         $uProfile[$upConfigManagerProperty.Name].Property.IsSearchable 
         ) {
        foreach($key in $PeopleThesaurus.Keys) {
          if($uProfile[$upConfigManagerProperty.Name] -match $key) {
            if(!$personDictionary.Contains($key)) 
            {
                $personDictionary += $key
                $save = $true
            }
          }
        }
      }
    }

    if($personDictionary.Count -gt 0) {
        Write-Host $uProfile[$employeeIDAttribute]
        foreach($item in $personDictionary) {
            foreach($entry in $PeopleThesaurus[$item]) {
                Write-Host " " $entry
                $x = $PersonThesaurus.Add($entry)
            }
        }
    }

    if($save) {
        #Write-Host "" # New line
        $uProfile.Commit()
    }
  }
  #exit
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.