Home > Microsoft SharePoint, SharePoint 2013 Search, SharePoint2013 > SharePoint 2013: Avoid default results in search result and content search web part with search box

SharePoint 2013: Avoid default results in search result and content search web part with search box

Hi Friends,

I faced one more issue recently related to SharePoint 2013 search, that I thought to share with you.

Scenario:

I have ‘Search Box’ web part and ‘Content Search’ web part on a page, search box is sending query keyword to content search web part to display results. Content search web part has couple of additional queries as following screen shot showing.

Search_Box_1

This query returning the results always and thus showing me the results before even started searching using search box web part, as shown in following image.

Search_Box_2

I wanted content search web part should show the results only when someone searches for it in search box, else results should not be displayed.

Solution:

I have modified the Content Search web part’s query like following, which given the expected results.

Search_Box_3

So after the query changes by default no results are displayed and I am getting results only when I searched using search box web part, as shown in following images.

Search_Box_4

Search_Box_5

The same changes will be applicable if you are using search results web part.

Hope this article will helpful for some of our friends, if any other good alternative for this found please let me also know about it.

  1. Mathias Crochat
    January 22, 2014 at 12:41 pm

    Just i was looking for, thanks guy !

  2. DNelson
    March 18, 2014 at 6:23 pm

    Thanks for sharing this. It works perfectly!!

  3. Nikita
    July 8, 2015 at 9:35 am

    Thanks a lot!

  4. Cyndera
    October 22, 2015 at 4:50 pm

    I know this post is quite old, but I wanted to say thanks anyway because it helped me as well. I am now trying to figure out how to eliminate the generic “Nothing matches your search” message that is still being displayed when a user goes to the page. In case this comment is being read, any help would be greatly appreciated. Thanks!

  5. Thippa
    April 29, 2016 at 3:03 pm

    Thanks very much it saved my time

  6. July 25, 2016 at 9:45 am

    Nice article sir..
    you have save my day..
    Thank You..

  7. Mung
    January 20, 2017 at 9:37 am

    Thanks alot

  8. December 12, 2017 at 4:07 am

    Just recently this resolution resulted in no results found for my custom result source. I had to remove the // to have the search results show up again. Now I have the orig problem of results showing by default. Anyone else experience this?

    • March 14, 2018 at 7:28 am

      Hi have you got any solution to your problem. I am facing same issue. Adding
      \\{SearchBoxQuery?} dont show nay results after entering search as well.and removing it shows bunch of default result which I dont want.

  9. March 13, 2018 at 11:02 pm

    Almost 5 years later and I needed this today. Fixed my issue. Thanks!

  10. Augusto
    January 8, 2019 at 9:05 am

    Hello. The solution works fine with \\{{SearchBoxQuery?} and with search values like “john*” but the search doesn’t return any value when the search text is “*”. I have to mention that I have defined other filter values in the Search condition:

    \\{SearchBoxQuery?} Department:I*

    Thanks for your help.

  1. July 25, 2016 at 5:43 am

Leave a reply to KD Web Cancel reply