With Moss, Microsoft has taken a huge step forward in enterprise search. Add to that the acquisition of Fast and there is no doubt that we will see a lot of interesting things in the SharePoint 14 version. But for now we have to work with what’s available Out-Of-The-Box and unfortunately that leaves us with a lot to wish for. As you might have noticed you have a simple and one advanced Search Web part and there is quite few options to do anything fancy with them.
So today I would like to share a solution that should be considered as a first step or a work-around. To implement something heavily used in your enterprise you should make a web part and by doing that you will have endless of opportunities, because, after all there are some quite powerful APIs to use if you just put your effort in it.
Enough with the yada yada. If you in the search box of you MOSS site type Title: Jerry and push the search button Moss will search the Metadata Property, Title. Moss has a couple of Managed Metadata Property sand you can of course create your own. (Stay tuned for my next post where I will talk more about how to do that and what Metadata Properties are, for now, let say that all the built in columns used could be used instead of Title in my example. Author, Status etc.) This is however not very user friendly and the end users doesn’t always know what the Metadata Property is named, making it impossible for them to get a good search result.
If you take a look at the URL on the results page (not if you using the advanced search) you will see that it has a querystring looking something like this: Results.aspx?k=title%3A%20jerry&s=All%20Sites.
What we see here is that after the k= we have the Managed Property title we used and then our search word Jerry.
This means that with some good old JavaScript and html form fields you can create, drop-downs, check-boxes and radio buttons with predefined Metadata Properties and values. And then in you Submit button you just add the information from your html form as a querystring and then send the user to your results page. The best thing with this is that you just add this to a Content Web Part and you can then design it in any way you want, lovely right?
A simple javascript for this purpose could look something like this (and bear with me, this is not fancy, just to give you a hint on how to do it):
<script language=”javascript”>{
function CustomSearch()
var product = document.aspnetForm.Service.options[document.aspnetForm.Product.selectedIndex].value
var baseURL = “/searchcenter/Pages/results.aspx?k=Product%3A”+product
top.location.href = baseURL;
return true;
}
<select name=”Product”>
<option selected>- Select Product -</option>
<option value=”ProductY”>ProductY</option>
<option value=”ProductX”>ProductX</option>
</select>
Then you just add button with a OnClick event:
<input type=”button” onclick=”CustomSearch()” value=”Search”>
As you also might noticed in the querystring, it has a s=All%20Sites this is the Scope So if you want your custom search box to only search for information in a specific Scope, you just have to add the s= [name of scope] to your URL before you send the information to the results page.
Remember don’t add any <form> tags, the Content Web Part don’t allow that.
Have you done any customization to the search boxes in Moss, I would be happy to hear about your solutions and ideas.
That’s it for now







i can not get my search limited to only one site collection through using scope or any other way. do you have any suggestions??
Do you mean in combination with the above mentioned way or at all? If the later, what platform are you using? MOSS, WSS?