Friday, April 4, 2014

Content Search Web Part “Hello World” using Query Rules

Helge Solheim did a post on how to do “Hello World” using the CSWP, where he retrieves a document with the title of “Hello World”.

Figured I’d do the same, using a Query Rule instead Smile

I first tried to create a rule which triggers on a search term, and then configuring the CBWS to execute that query. But turns out if you do this, the rule will not fire for some reason.

Hence it got a bit more complicated.

 

First off create a new Result Source, and accept all the defaults.

image

Next up I create Query Rule for this new result source “Hello World” with a promoted result. I make it trigger for any term and only on the “Hello World”  result source.image

image

Nest step is setting up the CBS webpart, triggering the rule. On the right hand you see the Special Term Result including the best bet I defined. I have also chosen the “Hello World” result source and no query what so ever.

image

I also configure CBS to return one item only, map Title and URL to be used in the template, and I pick SpecialTermResults as my result table, as this is the table containing promoted results.

image

Result looks something like the image below.

image