Content Search Web Part Results Issues

 

Content Search Web Part (CSWP) is one of the great web parts introduced in SharePoint 2013 and Office 365. This web part uses the Search API and index to dynamically display results based on specific queries and rules on a content page.

The way it works is pretty simple; when a user navigates to a page, the web part initiates a query based on different inputs such as search box keyword, URL parameter, token, etc. You can also apply filters, refiners, and apply relevancy to the search results to make your SharePoint experience much more enjoyable.

I have spent a lot of time building dynamic portals, and, of course, at the same time troubleshooting issues why results do not show up. Let’s take an example where you want to build an image slider that loads the content from an image library. It’s pretty simple to build this in CSWP, where you pass the URL where you want to display, add some filters and voila, the results should show.

CSWP Query Builder

The Query can look like this:

path:"<URL of the library>“(IsDocument:"True" OR contentclass:"STS_ListItem")

CSWP Refiner

In the above example I am submitting a query to load from a specific URL and return only the items. This will exclude for example, the AllItems.aspx page.

Let’s say you can build a complete portal based on CSWP, however, our topic here is not how to build a CSQP, but to troubleshoot why CSWP does not display results for you.

But wait, what if you are not getting any results back? Here are few tips to help you troubleshoot the issue.

  1. Is the content crawled? Make sure the content you uploaded has been picked up by search. You need to wait before the content is indexed. A good test is to use the general search to check if your content is indexed. If it is, then the issue is something different.
  2. Too many filters in your query refiners. If you have too many refiners, start removing them and check if your query is returning results or not.

In my recent scenario, my content was indexed, showing up in the default search results, and I had no filters. In fact, just adding the CSWP with no extra queries in it did not return anything. Typically, when you add the CSWP, it will automatically show you this:

Default CSWP

After further investigation, looking at the way the portal is configured, I noticed something not adding up in the Alternate Access Mapping (AAM). The default AAM of the portal was not the same as the one it is being crawled. In my case the default AAM was http://portal and in the search content source I had http://portal.contoso.com.

Here’s the AHA moment! AAM did not match the content source; once I made sure that the default AAM and content source are a match, the content started showing up in my CSWP.

  • Thursday, May 05, 2016 By : Mike Maadarani    0 comment