Difference Between Search Result Web Part and Content Search Web Part III: Result Types

Hi Again.

Today, I'll explain the Result Types. If we do a little bit of Googling then we will get very good articles / blogs on Result Types.

The following are a few good references for details of Result Types:

So here I'll not delve into Result Types but will discuss the use case (scenario) we have and how we implement using Result Types.

Use Case

We have a portal with many article pages, news pages and links. We have a requirement like on our main portal home page for showing the 5 article pages, news pages and links. So a total of 15 items. All we need to show in such a way that they have a common background for all 15 items without any gap between various types of results but multiple presentations to identify those. Like the previous link there should be “>>”, news pages item should show the modified date and article pages item should show the author.

Such as shown in the following example, with a Yellow background (this is just an example):

Article1 Author
Article 2 Author
Article 3 Author
Article 4 Author
News Item 1 Modified date
News Item 2 Modified date
News Item 3 Modified date
News Item 4 Modified date
>> Link1
>> Link2


Various Approaches

We have decided to implement this requirement with a Search, so in any approach we will require at least three Display Templates.

  1. The initial thought in our mind is 3 Content Search web parts adding in one zone and in the page layout add this zone to the Div tag so that we can have a common background for all the web parts.

    But this approach has one drawback. We need to add three Content Search web parts. On our portal we already have 4-5 search web parts so we are a little concerned about the performance and then maintenance. Need to maintain the three web parts.

  2. In the second approach, my team member suggested the Result Types. So we just need to create three result types and set rules like if the Article page content type then apply an article page display template, if News Article content type then apply the news display template and if a link content type then apply the link display template. And then we will require only one Search Result web part and need to configure the Search result web part to use Result Types as follows:



    Figure 1: Configuring Result Types in Search result web part

So here at least our performance and maintenance related problem is solved since we are using only one Search Result web part.

So basically here I want to focus on Result Types that are used to display results differently. But Result Types are available only with Search Results web part.

[Even though we will go with Content Query web part (CQWP) for this requirement, we will require three CQWP that need to be added in one Zone, the same as a Content Search web part.]

Thanks!

Feel free to comment and/or provide feedback if any or if you have any query.