Debugging setting properties in anonymous Search REST queries


Leveraging SharePoint 2013 Search REST API for anonymous users allows you to build powerful search-driven solutions. Often, particularly in the early stages of the project, queries might not work as expected. So how do you find out what’s wrong?

SharePoint 2013 Search REST API for anonymous users

SharePoint 2013 Search REST is a very flexible API that allows you not only to configure whether this particular API should be available to anonymous users but also allows you to choose which capabilities those users are allowed to use. This last part is done by specifying a white list of the allowed capabilities in the queryparametertemplate.xml configuration file.

Debugging setting properties in anonymous Search REST queries

In some scenarios, when working with anonymous Search REST queries you might notice, that even though you set a specific property in the query it is not being reflected in the query executed by SharePoint 2013 Search. In such case a good way to ensure that everything is working as intended is to verify that properties requested in the query are properly set in the query executed by SharePoint 2013 Search.

Before you will be able to see the detailed information about how the different properties are applied to the query, you need to increase the logging detail level for the SharePoint Server Search > Query category to Verbose.

SharePoint Server Search, Query category highlighted in Central Administration Monitoring configuration

Next, when you execute a query using the Search REST API, look in the ULS log for the entries referring to client-specified and overlaid properties.

Two ULS log entries highlighted in ULS Viewer

By examining the values you should get a better understanding of which properties are you trying to set and whether they are indeed being set on the query or not.

One reason for a property not to be set on a query is, that that particular property hasn’t been included in the white list in the queryparametertemplate.xml configuration file and SharePoint 2013 Search falls back to its default value.

Summary

Leveraging SharePoint 2013 Search REST API for anonymous users allows you to build powerful search-driven solutions. Common errors in setting query properties can be examined using the ULS log.

Others found also helpful: