An Unpleasant Refiner Bug in SharePoint Online

As always, I don’t know where to report issues with Office 365. So here I am carping in a public channel in the hopes that the right person sees it. This also may happen with SharePoint 2013 on premises, but I can’t recall.

Unpleasant SharePoint search refinerWhen I use a refiner that is based on a Lookup column, I’ll often see something like the attached image. As you can see, there are two clients listed: Anchor Glass and 29. Anchor Glass is the title of the item in the Clients list with the ID of 29, but it still doesn’t make sense (especially to those poor users). It’s as if the indexer isn’t smart enough to handle Lookup columns properly – but only some of the time.

This happens on multiple tenants, with different Lookup columns to different lists, but not consistently, or in any pattern I’ve been able to discern. Generally it’s the Title column we’re looking up into. Using a Lookup column into a list is almost always preferable to using Managed Metadata (IMO) because we can store additional data about the values in the list. For instance, in the Clients list above, we have the client contact info, who works with the client, when we started working with them, what the billings are, etc. Managed Metadata is worthless for that.

But the bug.

Has anyone else seen this? Any ideas on how to work around it?

SharePoint Online Search: Add a Refiner for Content Type

2015-12-21_14-00-52This is yet another in the “Things that Make You Go Hmm…” category. If I only had a nickel…

I would think that one of the most common needs on a search results page would be to add a refiner by Content Type. After all, we all have robust, sensical information architectures in place to improve performance in our organizations, right?

When we create a new search results page in a Search Center, we get a few refiners out of the box that look oh-so-promising.

First there’s ContentTypeId. We all know that Microsoft uses big, ugly ids and GUIDs under the covers all the time. Sometimes they translate easily into whatever they represent. This isn’t one of those times.

2015-12-21_13-37-48

Well, what about contentclass? That looks sort of almost useful. But it isn’t. Values like STS_ListItem_DocumentLibrary won’t really help anyone.

2015-12-21_13-37-35

Oh, I know. Let’s add the ContentType Managed Property. That’s what works almost everywhere else. Well, except here, as the values don’t make sense to humans, as they are things like application/pdf Document or application/vnd.openxmlformats-officedocument.presentationml.pres… Yes, the ellipses are appropriate here. Who know what that means?

2015-12-21_13-38-05

Finally, I found a blog post from Henri Merkesdal that retrieved my sanity. There’s a property way down the list called SPContentType that does exactly what we want.
2015-12-21_13-38-20

Ahhh. That’s much better. Thanks, Henri!

2015-12-21_14-00-52

Customizing Search Refiners in SharePoint 2010

Search RefinersI wanted to add some custom refiners to each of the custom search result pages I’ve been working on in a project. The steps to do this aren’t complex, but since I needed to read a bunch of posts out there to get it just right, I figured I’d write it up.

Create Custom Managed Properties

Only Managed Properties are available for use as refiners. While Site Columns automatically become Crawled Properties, they must be added as Managed Properties to use them as refiners (or in scopes, etc.).

To do this, we go to Central Administration -> Application Management -> Manage Service Applications -> Search Service Application -> Metadata Properties and whatever new Managed Properties we need.

Note that we cannot use the existing ContentType Managed Property in the refiners. If we do, we get the error

Property doesn’t exist or is used in a manner inconsistent with schema settings.

In order to use the Content Type as a refiner, we must create our own Managed Property which mirrors the existing one. I created a new Managed Property called ContentTypeRefiner and mapped it to ows_ContentType(Text).

Perform a Full Crawl

After creating the Custom Managed Properties, we must do a full crawl so that the new Managed Properties will be in the active index.

To do this, we go to Central Administration -> Application Management -> Manage Service Applications -> Search Service Application [you may have named this differently when you created it] -> Content Sources. From the dropdown for the relevant Search Scope, choose Start Full Crawl.

A full crawl can take a significant amount of time depending on the amount of content you may have, so it’s best to create all of the new Managed Properties before kicking one off.

Add Managed Properties into Refiners

To add the new Managed Properties as refiners in the custom search results pages, we do the following:

  • Navigate to the search results page
  • Go into Edit Mode
  • In the Refinement Panel (left side of the page) select Edit Web Part
  • In the Tool Pane, under the Refinement section, edit the Filter Category Definition XML to include the new refiners
  • Uncheck the Use Default Configuration box, otherwise your changes will disappear!

Note that any of the existing refiners can be removed. The order in which the refiners are included in the Filter Category Definition determines the order in which the refiners are shown, if there is enough content which contains that refiner’s metadata.

Here’s an example of what the XML for your own refiners might look like. This is the XML I added for the ContentTypeRefiner Managed Property. Most of the attributes are pretty self-explanatory.

<Category Title="Content Type"
  Description="Type of resource"
  Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"
  MetadataThreshold="5"
  NumberOfFiltersToDisplay="4"
  MaxNumberOfFilters="20"
  SortBy="Frequency"
  SortByForMoreFilters="Name"
  SortDirection="Descending"
  SortDirectionForMoreFilters="Ascending"
  ShowMoreLink="True"
  MappedProperty="ContentTypeRefiner"
  MoreLinkText="show more"
  LessLinkText="show fewer" />

Useful Reference Links