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:
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:
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!