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 –
Observe how the value of the WorkPhone property comes back as null.
Now go to the Search Schema, find the Managed Property and tick the Searchable box –
Run and incremental crawl and then re-execute the query, observe that now we get a value back.