Search box web part- using a single custom scope

It’s another one of those things that sounds so simple but ends up being ridiculously unintuitive to configure in SharePoint. I recently embedded a search box web part in a master page and wanted to have it search and return results from a custom list (Business Directory) in my site. So I ran through the usual steps of creating a ‘Business Directory’ display group and search scope for the list. I also set up a custom results page, ran a crawl and then configured the web part to use the Business Directory display group and hide the scope drop down (hidescopeDD). To my dismay I found that when I executed a search query using the web part, results from the entire site where returned rather than results just from my list. My custom results page had the search box web part configured in the same way but with the scope drop down showing (showDD). When I executed the same search in this web part the list results were returned.
So it seems the problem here is that the hidescopeDD DropDownModeEx for the search box hides the scope drop down but it also then defaults to the contextual scope; this:site rather than the only “real” scope in the specified display group. There are only 3 options to hide the drop down and none of these actually specify what the default scope should be (hidescopeDD, HideDD_NoScope, HideDD_useDefaultScope).
Fail!
So to get around this you can actually specify the scope you want to use in the search box AppQueryTerms attribute.
AppQueryTerms= scope:Business Directory
AppendQuery =false

The AppQueryTerms attribute is quite handy because you can use it as a filter in all sorts of ways. For example you can also specify the content type you want returned:
AppQueryTerms= content type:Business Directory Listing
Or the site you want to results to be returned from:
AppQueryTerms= site:http://siteurl

Advertisements

3 thoughts on “Search box web part- using a single custom scope

  1. great job, very helpfull. thanks for the post. I have tried to follow the same idea and found no success. here is what i have done,

    added a new searchbox webpart to my page and wanted to target it to the search to a specific scope and default to it at the same time, witout showing the scopes dropdown.
    i have included scope:abc in “Additional query terms”
    and unchecked the option “Append additional terms to query”
    i am using the custom target results page.

    any idea as to where i went wrong. much appriciate your response. thanks.

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