So, we’ve got a customer who’d hit the problem of the OSSSearchResults page that I’d mentioned before. To recap:
- Global Searches in MOSS use a Search Center page for showing the results. These are nice, configurable, and can be made do quite a lot.
- Contextual Searches (such as a particular list or site) use the standard WSS OSSSearchResults.aspx page. This isn’t nice and configurable, and changes will affect many sites.
Now, what would be great would be if we could have the contextual scope, but the global results page. Well, we can.For this example, I’ve got a library of ‘Travel Documents’. The documents all have an ‘Example Travel Expenses’ content type.
It struck me that I could restrict results to the scope of this list using standard SharePoint Search Scopes. I created a scope that restricted based upon the URL to the list. I called this scope ‘Travel Docs’.
Note that although the one rule here has no items matching against it, there are 8 in total, apparently. The total seems more accurate!
Now, we could go to our Site Collection settings and add the new ‘Travel Docs’ scope to the drop down list in the Search Box at the top of our pages…
… but this would apply throughout our entire site collection. We didn’t want users to be able to search this list from anywhere.
Instead, on the home page of our site containing the ‘Travel Documents’ Library we added a Search Box Web Part
When we went to configure it, though, we couldn’t set the scope. You can show the scope drop down or not, but you can’t force one. Also, although we could add extra words to the search query, we couldn’t add parameters to the search URL.
What we could do was point to a particular results page.
I created a new Search Results page, and pointed my new Search box toward it.
So, I’ve got a scope, I’ve got a search box, and I’ve got a results page. I couldn’t make the search box web part use a particular scope, but I wondered if I could make the results page. I went to it, and configured the Search Core Results web part. In amongst the settings, I found a field ‘Scope’. I typed in the name of my scope (i.e. ‘Travel Documents’).
Then I went back to my Search Box, and tried a search (for ‘Acme’):
Success! So, the scope gives us our contextual information, the results page uses that scope (rather than one being sent with the search query), and our search box takes people to that results page.
So, a query on a single list, but with a richer results page. The only down side – you have to set up a new Search Scope (although it doesn’t have to be available in the Scopes drop-down lists).