Declaratively Point a Site Collection at a Search Center

Yesterday I wrote about the SmallSearchInputBox, how scopes only appear if you set a search center for the site collection, and how to set the Search Center in code.

Well, as is typically the way with CAML, I figured out how to do this declaratively later. Or, more specifically, I found that there is a feature I could call declaratively that would do what I want:

search-center-url-feature

<!-- SearchCenter Url feature -->
<Feature ID="7AC8CC56-D28E-41f5-AD04-D95109EB987A" >
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="SearchCenterUrl" Value="~SiteCollection/Search/" />
</Properties>
</Feature>

Yup, all I need to do is put that into my site definition…

Advertisement
Declaratively Point a Site Collection at a Search Center

Programmatically configure the Small Search Box to show scopes

Sharepoint’s ‘ordinary’ sites, such as Team Sites or Blank Sites, have a small search box (the SmallSearchInputBox) at the top which does not show search scopes, as we would be used to in a Collaboration Portal, for example…

search-blank-site-default

The reason for this is that they are not, by default, pointed at a particular Search Center – so they don’t have any idea what scopes to show. However, you can set this through the Site collection Search Settings…

search-site-collection-settings

And suddenly, your search scopes appear! Hurrah!

search-blank-site-now-with-scopespng

Now, what if we are creating a bunch of site collections? (Our current project could create quite a lot of site collections. And we need them created automatically, as required). Can we point them to a specific search center automatically? Continue reading “Programmatically configure the Small Search Box to show scopes”

Programmatically configure the Small Search Box to show scopes

Search a single Site

Previously, I’d posted about a customer who wanted to search a single list from a Search Box web part, but have their results shown in a Search Center results page. We ended up using a custom scope to do that.

This time, I’d a slightly different requirement. Another customer had a number of links, and these links would include search terms. They wanted to be able to restrict those searches to particular sites – and not just one particular site or set of sites, but to lots of different sites.

This made adding a scope an unappealing prospect. You’d have to add lots of scopes, and it’s not very dynamic.

One thing you can do in SharePoint search is search on the value of a particular managed property. A normal search would have query parameters like:

?k=King%20Lear

That would search all of SharePoint for ‘King Lear’. Well, we could also filter by properties – so we could do a search for:

King Lear site:http://intranet/somesite

This would encode to:

?k= King%20Lear%20site%3Ahttp%3A%2F%2Fintranet%2Fsomesite

and would restrict our search to a particular site (and subsites, actually – but close enough!)

This set me wondering, though – there is a URL managed property. Could I use this to restrict my search, rather than having an additional scope? Trying to restrict the search based on this didn’t seem to work very well. My results were… strange. I can’t figure out a logic, other than I was missing a lot of results. If anyone figures out what was going on, let me know.

So, the short is, I believe the above is a good way to restrict your results to a site. However, I can’t find an easy way of restricting results to a single list via a URL. I might have, if I’d spent longer looking!

Search a single Site

Search a single list, and don't use the OSSSearchResults.aspx page…

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. Continue reading “Search a single list, and don't use the OSSSearchResults.aspx page…”

Search a single list, and don't use the OSSSearchResults.aspx page…

Search Scopes and Site/List Context…

Came across an interesting problem from a customer – they’ve got a customised master page which doesn’t have ‘Site’ or ‘List’ level searches. They’ve got search scopes (such as ‘People’ or ‘Documents’ or ‘All Sites’), but across their entire SharePoint system. For example, this search:

will take us to our customised results page:

Note the Document Date column, and navigation breadcrumbs – these are custom.

The customer has added the search box web part to some pages, though, and this does display ‘Site’ or ‘List’ level scopes. Running a search against these scopes:

Takes us to this search page:

Yup, that’s the WSS3 standard search results page. You can see this in the So, can I change that?

Well… no. Proving that nothing is new under the sun, Mark Arend has a good post about this problem of contextual and custom search scopes. His explanation makes sense, too, but like he says, it doesn’t really justify the issue.

One option that he doesn’t mention is that you could use an HTTPModule to intercept the call to the OSSSearchResults page and forward it to our own custom results page. I might prototype that and post about it tomorrow.

Let’s hope that SharePoint vNext fixes this, ‘cos inconsistent search results depended upon contextual vs custom scopes will just confuse.

Search Scopes and Site/List Context…

Create an Image only Search Scope in Sharepoint

Previously I’d looked at having a search that shows thumbnails of images in SharePoint. I modified the results page to do this – but the results themselves would still show non-Picture items (e.g. documents, pages, etc.). In this post, I’ll configure up a new Search Scope for images only. Continue reading “Create an Image only Search Scope in Sharepoint”

Create an Image only Search Scope in Sharepoint