Should I use the SharePoint Search API?

Duane OdumI was recently tasked with creating an effective means of tracking/reporting on project tasks in SharePoint Online.  Based on the requirements I setup everything “out of the box” to show what could be accomplished by using simply using Content Types, Site Columns, Managed Properties and Search.  The client liked the outcome but didn’t necessarily love it.  Search API to the rescue.

If you are not familiar with the SharePoint Search REST API click the link here to find out more but as the name implies it essentially allows developers to interact with SharePoint’s Search via REST.  There are definitely times where we will want to stick to making direct REST calls to perform GET operations but using the Search API we can eliminate a lot of REST calls and resource usage as we can get all data pertaining to our query from a single call against the Search API vs. looping through sites/lists to find the information we need.

Of course the Search API does have a few downsides:

  1. New/edited items are not going to be displayed in your results until SharePoint has crawled the content.
    1. In SharePoint Online it seems to take between 5 – 10 minutes depending on the amount of content being crawled whereas SharePoint On-Premises (2013 and above) the time frame is based on your farms incremental crawl schedule.
  2. In order to take full advantage of the Search API you need to establish a solid baseline for your content including but not limited to: Content Types, Site Columns, Managed Properties and Enterprise Search.
    1. This is necessary to make sure you can easily filter and grab the data you are looking for but I consider this part of a normal SharePoint project implementation.
  3. Whomever is managing the SharePoint environment needs to ensure that when new content is added it is done with the appropriate Content Type/s in place.
    1. It does no one any good to create a solution that isn’t going to be utilized.

So, how exactly did the Search API come to the rescue?  I was easily able to setup some “report” pages on the top level project site that allowed users to select various filters.  Once they choose the filter the information requested is displayed in a nice, clean format to enable them to report by Project, Task Status, Assigned To, Due Date and Task Priority.  All of these things could be done using the “out of the box” search page configured initially but the presentation of the Refinement Panel and Results were simply not enough to get buy in.  Giving them filters and displaying the data in a nicer, mobile friendly way made a huge difference for the client and as an added bonus I actually got to write some JavaScript code.

If you would like to delve further into the SharePoint Search API I would highly suggest taking a look at the SharePoint Search Query Tool on CodePlex.  It will allow you to connect to your environment and test out queries to your hearts content.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s