SharePoint 2013: How to Create Custom Result Blocks using Query Rules

In this article we are going to explore SharePoint Search Custom Result Blocks configured using Query Rules.

What are Results Block?

A Result Block is set of filtered results that are combined with core search results and displayed on top of the core search results as a block or can be ranked with in the Core Search Results depending on how you configure it to be.

It is not required to have results for Result Blocks from Local Search index only. A Result Block can use any of the result source from the below list:

  1. Local SharePoint farm
  2. Remote SharePoint farm
  3. OpenSearch
  4. Exchange

In order to setup this demo, I have prepared the system with some test User Profile data as described below:

I have setup three User Profiles with different job titles as shown below:

User 1 : SP\Administrator

1

User 2 : SP\Guest

2

User 3 : SP\SPDeveloper

3

In order to configure Result Block, we need to start it with Query Rules configuration by using the following steps:

Go To Site Settings

4

Under Search, Click Query Rules

5

Choose Result Source as applicable, here I am working on Local SharePoint Search Results

Click on New Query Rule

6

Under General Information, Enter Rule Name

Under Query Conditions,

  1. Select Query Options as needed, here Advanced Query Text Match works for me
  2. Select phrases which you want to be included while matching query text issued by the user

7

Click on Add Result Block

8

Enter Block Title, this title will be added as Header with the Result Block displayed on Search Result Page.

Click on “Launch Query Builder” Button

Select the number of items to be displayed inside the result block from Items Dropdown as shown below, here I will go with 4 items to be displayed inside Result Block.

9

Configure the Query as shown below:

  1. Select a Result Source to as target for the query, here I am using “Local People Results” as I have setup test data in User Profiles.
  2. Choose suitable property to filter on from Property Filter Drop Down
  3. Choose suitable Operator
  4. Choose suitable value type
  5. Choose suitable value as shown below
  6. Click on Add property Filter
  7. This will add the query filter to the Query Text box
  8. Click on the Test Query Button, to validate the query you have just created
  9. Search Result Preview Section will show few of the total search results returned by the query just configured in the previous steps
  10. Click OK to close Query Builder Dialog

10

Always Choose the setting as shown below, if you want to have Result Block Displayed on top of Core Search Results as a separate block.

You can also choose to display “More” Items link, in case you want to show case the complete result set retuned based on the Query Rule. For this to happen you have to have a separate page configured with the same query to show all the results. I am choosing here not to display it.

11

And That’s it.

We are all done with the configuration work for the result block and now it is time to test the results returned based on the configuration we did above.

Final Configuration would look like as shown below:

12

In order to test the scenario, Enter “MOSS” or “sps” or “wss” as Search Term, remember we added “MOSS, sps, wss”in the search phrases while configuring Query Rules.

Since we got the search term “MOSS” or “sps” or “wss” as a Query issued by user, SharePoint Search System identifies a suitable query rule by matching this term with the phrases we specified while configuring Query Rules above and filter out the results based on the query we specified, in this case it was “JobTitle:SharePoint”, which mean finds any Profiles for which Job Title Property contains the word “SharePoint” .

Based on the query treatment as mentioned above we got two profiles “User 1 : SP\Administrator” with Job Title “SharePoint Administrator” and “User 2 : SP\Guest” with Job Title “SharePoint UI Designer”, displayed as valid results inside Results Block.

On the other hand we do not get “User 3 : SP\SPDeveloper” listed in the Result Block as Job Title Property for this profile is blank, due to this “JobTitle:SharePoint” match gets failed and this result get filtered out as shown below.

13

14

15

Hope this will help someone in need…

Advertisements

One thought on “SharePoint 2013: How to Create Custom Result Blocks using Query Rules

  1. Hi there! I am so grateful that I found your website. I really admire the dedication you put into offering the in depth information for free. I will definitely come back to your website for more. Keep up the good work. By the way, this system helps me making around $650 per day, if you allow me, I suggest you to take a look at this secret offer page to access your very own turnkey software business to increase your online revenue. Wish you more success, all the best!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s