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:
Our query will append our search term! Next, turn off the drop down list of scopes:
Finally, choose your results page. You would probably want to point this at your search center:
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.
One thought on “Contextual Searching Via Search Box AppendQueryTerms”
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.