Richer search results through the use of property restrictions with SharePoint 

Tags:

A while back I wrote a couple posts like this one and that one about creating an advanced search using query string manipulation with JavaScript.  They introduced the idea about what is possible with some creative thinking, but it never covered the options available to actually put into the query string to take it to the next level.  This post covers some of those options and talks a little bit about the search behavior for MOSS (or Search Server).

Microsoft Office SharePoint Server boasts robust enterprise search capabilities that companies can immediately take advantage of once the product has been installed. Most users simply type a search query into the search box and then get results, but search box supports other syntax that can be used to get better results. If you don’t have MOSS, keep reading because everything also applies to Microsoft Search Server. The Express version can be downloaded for free and used to bring the same search capabilities to WSS 3.0.

By default, when you type in terms into the search box SharePoint will assume that there is an AND between all of the terms. But unlike some other search engines, Boolean operators are not supported out of the box. The underlying SharePoint search API supports Booleans, but taking advantage of it requires custom code or 3rd party web parts.

It is often overlooked, but search box also supports the use of restrictions. Just like the name implies, restrictions are specific criteria that limit the search results to only what is specified. The restrictions can be typed directly into the search box to allow for greater control of what is being searched.

To use a restriction, you would type into the search box in the form restriction:”restriction value”

Note that if the restriction value has more than one word it is necessary to use quotes. 

The following is a list of available restrictions and examples of each:

Property name

Allows queries to be performed against a specific metadata property.

city:”New York”

Scope

Specifies the scope to be searched.

scope: MyCustomScope

File type

Specifies the file type to be searched.

filetype:docx

Site

Filter by site.

site:http://intranet


Note: To use a custom property name, you'd need to create a managed property and map it to a custom field or fields. For more information on creating your own managed property check out:

http://blog.tylerholmes.com/2009/01/sharepoint-searching-with-managed.html

If multiple restrictions are used on the same property, SharePoint will assume an OR between the terms so that the results are a union of the terms. For example if you typed the following into the search box:

site:http://intranet site:http://extranet

The results that were returned would return all of the values from the site http://intranet and all of the results from the site://extranet. However, if multiple filters are applied to different properties the results would be the intersection of those values. So if the following was typed into the search box:

site://intranet/hr DocumentType:benefits

This would return all results from the HR site where the content includes the term “benefits” as the value for the property “DocumentType.”

As I mentioned at the beginning of this post this technique can be used in conjunction with Javascipt to achieve an advanced search that is more user friendly than the typical Advanced Search. But if all you want to do is use these techniques to simply show off for your friends about your mad search skillz that works too.

 
Posted by John Ross on 3-Feb-09
0 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
 

Links to this post

Comments

Leave a comment





CAPTCHA Image Validation