Retrieving values of Managed Properties in SharePoint 2013 Search REST API

Having just spent the best part of a day trying to figure out how to query values of Managed Properties within a SharePoint 2013 App using the new Search REST API, I thought I would share with you how it’s done.

There is a real lack of decent MSDN documentation at the moment (especially around the search REST API – the word ‘search’ is mentioned three times in three pages of documentation!) and there aren’t many blog posts as people are only just getting started with SP2013. Over the coming few months I expect we’ll see much more content published by SharePoint MVPs and bloggers.

I did find one decent blog post by Nadeem Ishqair which lists the Query Parameters available for the query endpoint in the Search REST API.

One thing tripped me up though, in the above blog post it says that when using the selectproperties parameter to retrieve managed properties the ‘Retrievable’ flag must be set to true in the Search Schema.

“Specifies the list of managed properties to return for each search result item. For a managed property to be returned; the Retrievable flag must be set to “true” in the Search Schema.”

Whilst this is true you also need to set the ‘Searchable’ flag to true otherwise the result will come back as null in the query. In the below example I am using the following query to get the value of the WorkPhone Managed Property from a Contacts list –

http://app-b425a64b04c315.apps.mydomain/sites/devsite/myapp/_api/search/query?querytext=’intelligent’&selectproperties=’WorkPhone’

Observe how the value of the WorkPhone property comes back as null.

SP2013 Search Rest API Results

Now go to the Search Schema, find the Managed Property and tick the Searchable box –

SP2013 Search Schema

Run and incremental crawl and then re-execute the query, observe that now we get a value back.

SP2013 Search Rest API Results

Hope that helps someone, I’m glad to have this problem fixed – now on to the next thing, trying to set that searchable flag using the Javascript Client OM!!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">