Automagic Managed Properties in SharePoint 2013 search.

The ability to map crawled properties to Managed Properties in SharePoint search has been around for a long time, This enabled you to take those custom fields you created in your content types, and make use of them in your search results XSLT rendering.The big change in SharePoint 2013 is that this can happen automatically for you ready for use in the new display templates!

The process to achieve this on a content type was as follows:-

  1. Create Content type.
  2. Add custom fields to content type.
  3. Assign content type to a list.
  4. Create a test item from the content type.
  5. Ensure all custom fields contained a value. (This ensures all the properties are picked up in the crawl)
  6. Perform a crawl.
  7. Check the Crawled Properties in search and check the new properties are visible
  8. Mapped the crawled property to a new Managed Property.
  9. Perform a crawl again to map the Content type result to the new managed property. (A full crawl was preferred as this ensured any existing items already in the index had the managed properties added. If only new items were being created then an incremental was sufficient.)
  10. Use the new Managed properties in your search XSLT.

Overall, a fairly convoluted process, but ultimately successful and the contents of the managed properties could be viewed using a small snippet of XSLT to output the key value pairs as raw data.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>

This process, although ultimately successful would not have worked in SharePoint 2013 due to the changes to the search infrastructure. With the ability of site owners to create their own Managed Properties it could be difficult to both train them in the process, and also help them understand why their results are not instantaneous.

As a result, the process has been automated somewhat in 2013, with Managed properties being created for you during the crawl process (For all SITE COLUMNS only!). This is a great improvement on the process from 2010 and should go some way to helping the training of site owners with regards to customising search in their sub webs.

There are still some limitations though, although these will be pretty minor:-

  • To be picked up, the new items must be crawled. If you’re not using Continuous crawling, this will be limited to when your incremental crawls run.
  • The column must be a site column!
  • To be picked up, crawled properties MUST have a value.
  • To be applied to items already existing in the index, a full crawl will be required still. (Most of my clients would run these at a weekend, so the new managed properties would be applied to existing documents then.)

So the process now becomes:

  1. Create Content type.
  2. Add custom fields to content type.
  3. Assign the content type to a list.
  4. Create a test item from the content type.
  5. Ensure all custom fields have a value.
  6. Wait a minute for the continuous crawl to pick up the item.
  7. Go to Managed Properties in the Search Admin/Site Collection Search Admin/Web Search Admin
  8. Search for your custom field in the list.
  9. Use Managed Property in search results display template (More on this in the next blog post!)

You’ll notice that SharePoint assigns a property name based on the type of field detected. For a full list of those field name templates, please see the official MSDN documentation for this process which can be found here. (http://technet.microsoft.com/en-us/library/jj613136.aspx)

So let’s see this in action.

First let’s create a new content type called MyFirstContentType

clip_image001

And then add a couple of Site columns to it.

  • SiteCol1 – Single line of text
  • SiteCol2 – Choice field (Yes/No/Maybe)
  • SiteCol3 – Boolean (Yes/No)

Now we’ll create a document library that uses our content type, Click on add an app and choose Document Library. I called this one ManagedProp Documents.

Now add the content type to the document library (Same as in 2010, nothing new here.), then add a new column directly to the library called Nonmapped that uses single line of text.

Make sure that you have the add to all content types box ticked.

Now create a new document, or add one to the library and populate all of the custom fields with data.

clip_image001[4]

Now, if you have continuous crawling enabled, you should be able to view the crawled properties very soon. If like me you have crawling disabled on your test box, Just run an incremental crawl now.

Once the crawl is complete, we’ll go an take a look at the crawled properties in our site collection search schema. (You could do this in the Search Service application, or indeed the subweb if desired!)

clip_image001[6]

In the schema screen, click on Crawled Properties at the top

clip_image002

In the search box, type "SiteCol" and click on the green arrow, your crawled properties will appear below and if the processing has finished, your mapped managed properties will be displayed also.

clip_image003

If we now search for nonmapped in the same box, you’ll see that whilst our library field has been crawled, it hasn’t been automatically mapped as a new Managed Property.

clip_image004

I hope this helps you understand how automatic mapping of managed properties works now in SharePoint 2013. In the next post, I’ll be showing how we expose these mappings in Search results, and how to see them in their raw form to help with development.

Paul.

1 ping

  1. […] by Paul Hunt (This content is also available on my personal blog) […]

Leave a Reply

Your email address will not be published.

*

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