Create a Simple SharePoint 2013 Employee Directory on Office365 – Part 4 – Search Schema

In the prior posts in the series, we’ve seen how to set up a page for our employee directory and then create Display Templates to render the information we want for each person, along with a nice alphabetical filtering capability.

Up to this point, things have worked pretty much the same as they would in an on premises installation of SharePoint. With Office365, though, this is where things get a lot more complicated. I want to thank my search guru Mikael Svenson (@mikaelsvenson) for his assistance with this part of the work. This is another instance with SharePoint where the steps should be simple, but they aren’t when you add Office365 into the mix: it only gets harder.

In the listing we’ve made so far, we’ve had little trouble displaying the User Properties we want to see in the directory. Adding in some slicing and dicing requires a bit more fancy footwork. After all, if we can’t find people, it’s not much of a search-based solution, is it?

Each property we want to use in a filter we build needs to be “Sortable”. If we want to use a property in a refiner – those lists of values on the left side of the Search Results page – those properties must be “Refinable”.

For some unfathomable reason, out of the box the LastName property is not “Sortable”, nor is it “Refinable”.  The FirstName is “sortable”, but to me it’s a lot less likely that you’d want to sort or filter on FirstName than LastName. If we want to sort by Lastname, we’re out of luck. In Ari Bakker’s (@aribakker) post that shows how to set up a simple a Employee Directory on SharePoint 2013: How to: Create a Simple SharePoint 2013 People Directory, he shows how to tweak the Lastname property to make it sortable.

If you go to the Search Schema settings (Admin / SharePoint / search / Manage Search Schema), you’ll see that this is the case.

2015-02-06_14-45-42


Update 2016-11-02: Thanks to eagle eyed reader David (see his comment below), the LastName Managed Property is sortable on Office 365 now, at least in one of the tenants I checked. If that’s the case in your tenant, you won’t need to jump through this set of hoops.


In Office365, we’re not able to change the attributes of the out of the box User Profile properties, though. If we try to, they are all simply grayed out; we can’t touch them. This is where our path diverges from on premises installs.

On Office365, there is a very big set of dummy properties named RefinableString00, RefinableString01, etc. There are 100 of these String properties. There are also sets for Date (20), Decimal (10), Double (10), and Int (50). If you need any more of any of these, you’re stuck, so use them wisely.

Search Schema - Refinable Strings

Because the Lastname is a a string-valued property, we’re going to use one of the RefinableString dummy properties. What we do is map the RefinableString property to a crawled property. Here I’ve chosen RefinableString00 because I haven’t used it yet. Here are the steps to set up the mapping:

  • Click on the RefinableString00 property in the search schema listing
  • Scroll down to the section for Mappings to crawled properties
  • Click on the Add a Mapping link
  • Find People:LastName by typing “Lastname” in the search box and clicking “Find”

2015-02-06_14-52-51

 

  • Select the People:LastName property and click OK
  • You can only map to one Crawled Property, even though the UI will allow you to select several. As much as I wanted to include People:SPS-PhoneticLastName to match the LastName Managed Property, I couldn’t. I had to settle for just People:LastName, (which should be fine).

Lastname Mapped Properties

  • Scroll to the Alias setting and give the property a name you’ll recognize. I’ve used LastnameSortable.

Add Alias

  • Save the RefineablerString00 property by clicking OK

Now you still have a property named RefinableString00, but it has an alias of LastnameSortable (if you used the same name as I did) and it is mapped to the People:LastName property, meaning that RefinableString00 will get the same values as People:LastName.

RefinableString00 Configured

Perfect, right? Now we can just use that LastnameSortable property in our slicing and dicing tools and we’ll be all set!

Not so fast, Kemosabi. On Office365, we have no control over search crawling. We can’t just fire off a crawl to update the index like we can on premises. (In either case, we have to be admins, but that’s not the difference here.)

A User Profile will only be re-indexed if a value in that profile changes. For example, if I change my MobilePhone or a new value syncs over from Active Directory, then the next crawl will pick up that change and the value will be available in the search index. We’ve mapped the People:LastName property to the RefinableString00 property, but since no User Profiles were changed in the process, it makes no difference. We can’t just push the re-index button on Office365.

The only way we (Mikael, and therefore I) know to change every User Profile so that it will be indexed is to run a Powershell script that “touches” every profile. This is down and dirty stuff, folks, and not for the squeamish. You might want to enlist your local Admin Superhero to help you with this part.

2015-02-06_14-58-03Mikael built a script that loops through all of the User Profiles; copies the SPS-Birthday property value; sets the SPS-Birthday property to an arbitrary value; saves the profile; sets the SPS-Birthday back to the original, saved value; and saves the User Profile. Yes, for every single User Profile in the User Profile Store.

The one problem I had was that SPS-Birthday was almost never available in the User Profiles in the organization I was working with. Mikael adapted his Powershell script to also work with Department, which ought to be there more often. For the company I originally muddled through this with and their 100 or so employees, this wasn’t a big deal; the Powershell script ran through in a few minutes. If you are in a larger organization, the script might take hours and could possible timeout along the way. That said, it will work. Eventually.

I’m not going to go into all of the details on how to run the Powershell script. Instead, head on over to Mikael’s post “How to trigger re-indexing of user profiles in SharePoint On-line” and follow his instructions.

Once you’ve run the script, you’ll need to wait for some period of time – we don’t have any way of knowing when these crawl jobs actually happen. Experience shows that this will be 2-8 hours, but it can depends on the load in your tenant’s hardware. Once the values are indexed, you can start to use them in your Employee Directory.

The next step is to add some of the slicing and dicing capabilities. We couldn’t do that before we set up the RefinableString00 aka LastnameSortable property. If we had tried to use the Lastname property, we’d just get errors in the page I know this from experience). Errors that tell us precious little about what the actual problem is. Correlation ID!

Ari’s post shows some slick additional sorting capabilities that it would be nice to add at the top of the page. Sorting by Lastname or Firstname might make finding the person in the middle of the list by default a little easier to find. In the next article in the series, I’ll show you how to set those sorting capabilities up.

Series Navigation<< Create a Simple SharePoint 2013 Employee Directory on Office365 – Part 3 – Create Display TemplatesCreate a Simple SharePoint 2013 Employee Directory on Office365 – Part 5 – Sorting & Refiners >>

Similar Posts

46 Comments

  1. We are having trouble getting LastnameSortable to show. We followed the steps to set the search metadata, ran the script to update all the user profiles and waited and verified the crawl ran. We’ve tried it at the Tenant level and Site Collection level.

    When I look at the sortable properties under build query it doesn’t show as an option and the string001 doesn’t seem to sort anything. I also don’t see lastnamesortable as an option in the dropdown / json.

    This might not make a difference in the lastnamesortable showing, but right now I have “Show Ranked Results” checked in the settings section of the web part. Is that what you guys are using?

    Any help is greatly appreciated – we are rolling soon.

  2. how to get birthday and hire date on the page from user profile as name title and department is coming i required birthday and hire date also can i get it throught this way plzz guide me

    1. @saaani:

      You’d need to check to see if those are managed properties and query for them if they are. Otherwise, you’d make them managed properties as I did with Lastname here.

      M.

  3. Great article. I was able to follow along and build the site and it works great. for some reason I cant add my global navigation or custom logo to the site. Its like there is not enough space up top or on the side for navigation links. did I doo something wrong?

  4. Great article! Extremely useful! Thank you! Any chance you’ll have time soon for the next installment to show how to set up sorting capabilities?

  5. Mark, I would like to refine the search to only include people with CurrentItem.OfficeNumber populated, could you help with that query? I think I need to map it to a String and then refine by that

  6. Hi Marc, Great article series. BTW – LastName looks to be sortable in Office 365 managed properties now. I have also created a refinablestring and mapped properties to it during my testing however the order is not A-Z. For example surnames appear: Ding, Duran, Dahl. Have you seen this behaviour or has your sorting been working fine? – I figure should stop trying to fix this if it’s expected to be a bit flaky.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.