Contextual Searching Via Search Box AppendQueryTerms

I’ve been looking at using the Search Box web part for a light-weight contextual search.

SharePoint allows you to search ‘This List’ or ‘This Site’. Unfortunately, these searches always show the ‘OSSSearchResults.aspx‘ results page, which is built into SharePoint, can’t be modified, and this means that you can’t use your normal ‘Search Center’ experience, which is usually modified and optimized for your users.

You can add a ‘context’ to a search with some of the search query terms. “Site:http://example/sites/docs” for example would restrict results to those below that URL. So, is there any way we can add that to our query?

Well, the Search Box Web Part has ‘Additional Query Terms’. These can be appended to our query. So, if we set this, and check the check box:

append-query-terms

Our query will append our search term! Next, turn off the drop down list of scopes:

select-scope

Finally, choose your results page. You would probably want to point this at your search center:

target-results-page

And now searches from that web part will be limited by a URL context. I know, it isn’t great – you have to set up a web part for a particular context. This means you might need lots of Search Box web parts. But it does offer a very easy way of getting that search context – and you can point the web part at whatever results page you like, so you can get your customised results page.

Advertisement
Contextual Searching Via Search Box AppendQueryTerms

One thought on “Contextual Searching Via Search Box AppendQueryTerms

  1. Rob says:

    Hi,

    Just to say this really helped me out. A point of note is because I had a space in my URL I had to use the escape characters (e.g. Knowledge%20Base). Apart from that it does exactly what it says on the tin.

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.