Featured in Alltop

SharePoint Best Practices Conference Banner and Web Site Link

Professional Microsoft Office SharePoint Designer 2007

Archives

Categories


Links




Making Sense of the SharePoint World


The "Language" of Advanced Search (Part 2)

Sep-52008

This is the conclusion of a two-part article about customizing the SharePoint (MOSS), and Search Server, Advanced Search Web Part. In Part 1, you learned about the basic settings of the Web Part - which search options are shown, and how they are labeled. In Part 2, I'll show you how to change which language and document type filters are available to your users.

We completed Part 1 by describing how to configure groups for the Display group option in the "Scopes" section of the settings task pane...

Below the Display group option you will find the options for showing and labeling the language and result type pickers.

image

Checking the checkbox shows the picker, and entering text in the label field replaces the default label text. Just as with the other choices, clearing the text will restore the default label for the selection.

The next group of settings is "Properties", and this is where things start getting a bit more complicated.

image 

Notice that there are only three options:

  • A "Show Properties" checkbox
  • A section label
  • A "Properties" text field.

Just as before, the checkbox and label fields display and label the Properties list. But it is the Properties field which really interests us.

In the small part shown in this text box, you see the beginnings of an XML definition...

image

As they say, "this is just the tip of the iceberg". This XML is actually over 100 lines long! That is because it provides definitions for virtually everything else on the Advanced Search form. If you highlight the field, you will see the "elipsis" button as shown above. Clicking this will summon a larger text editing window:

image

Note: There are no line-breaks in the default XML. They are provided in the following examples for clarity.

There are four primary nodes under the root:

  • LangDefs
  • Languages
  • PropertyDefs
  • ResultTypes

Modifying the Language Filters

LangDefs, or Language Definitions, provides a list mapping all of the languages that SharePoint Search supports, ranging from Arabic to Vietnamese. A typical LangDef sub-node looks like this:

<LangDef DisplayName="Lithuanian" LangID="39" />

The nodes for the default languages are:

<LangDef DisplayName="French" LangID="12" />
<LangDef DisplayName="German" LangID="7" />
<LangDef DisplayName="Japanese" LangID="17" />
<LangDef DisplayName="Spanish" LangID="10" />

The LangID parameter is used in the next section, Languages. The Languages section, by default, lists the four nodes for French, German, Japanese, and Spanish:

<Languages>
  <Language LangRef="12" />
  <Language LangRef="7" />
  <Language LangRef="17" />
  <Language LangRef="10" /> 
</Languages>

The LangRef parameter is the LangID parameter from the LangDefs node of the desired language. To add another language to the list, simply add another Language Node. To remove one, remove the node. The languages are presented in the order listed. Substituting the code for Lithuanian(39) for Japanese(17) in the Languages section gives the following results in the Advanced Search form:

image

Properties and Result Types

Just as LangDefs were used for Languages, the PropertyDefs are used for the ResultTypes. The actual implementation is a bit more complex.

Here is the default PropertyDefs node and its children:

<PropertyDefs>
  <PropertyDef Name="Path" DataType="text" DisplayName="URL" />
  <PropertyDef Name="Size" DataType="integer" DisplayName="Size" />
  <PropertyDef Name="Write" DataType="datetime" DisplayName="Last Modified Date" />
  <PropertyDef Name="FileName" DataType="text" DisplayName="Name" />
  <PropertyDef Name="Description" DataType="text" DisplayName="Description" />
  <PropertyDef Name="Title" DataType="text" DisplayName="Title" />
  <PropertyDef Name="Author" DataType="text" DisplayName="Author" />
  <PropertyDef Name="DocSubject" DataType="text" DisplayName="Subject" />
  <PropertyDef Name="DocKeywords" DataType="text" DisplayName="Keywords" />
  <PropertyDef Name="DocComments" DataType="text" DisplayName="Comments" />
  <PropertyDef Name="Manager" DataType="text" DisplayName="Manager" />
  <PropertyDef Name="Company" DataType="text" DisplayName="Company" />
  <PropertyDef Name="Created" DataType="datetime" DisplayName="Created Date" />
  <PropertyDef Name="CreatedBy" DataType="text" DisplayName="Created By" />
  <PropertyDef Name="ModifiedBy" DataType="text" DisplayName="Last Modified By" /> 
</PropertyDefs>

These represent the standard managed properties used by SharePoint Search. Each PropertyDef provides the actual managed property name, a DisplayName (or Friendly Name) for use in the Property Restrictions dropdown, and the DataType, to allow the UI to provide appropriate comparison prompts. If you define your own managed properties in Search, you will need to manually add each property to this list if you wish your users to be able to choose them in the "Add property  restrictions" section. In addition, you will need to add them to the appropriate ResultTypes.

The ResultTypes node contains the definitions for the items which appear in Result type dropdown:

image

A typical result type definition, for Word documents, is listed below:

<ResultType DisplayName="Word Documents" Name="worddocuments">
  <Query>FileExtension='doc' Or FileExtension='docx' Or FileExtension='dot'</Query>
  <PropertyRef Name="Author" />
  <PropertyRef Name="DocComments" />
  <PropertyRef Name="Description" />
  <PropertyRef Name="DocKeywords" />
  <PropertyRef Name="FileName" />
  <PropertyRef Name="Size" />
  <PropertyRef Name="DocSubject" />
  <PropertyRef Name="Path" />
  <PropertyRef Name="Created" />
  <PropertyRef Name="Write" />
  <PropertyRef Name="CreatedBy" />
  <PropertyRef Name="ModifiedBy" />
  <PropertyRef Name="Title" />
  <PropertyRef Name="Manager" />
  <PropertyRef Name="Company" /> 
</ResultType>

You might wonder, "Why are all of these properties listed here, when they were already defined above?"

The answer is simple, not all properties apply to every document type. Something few people have noticed is, when you select a result type, the property restrictions list changes to reflect the properties defined for that result. For example, a Zip file would not have metadata for most document properties. if you have added a Zip iFilter to your search environment, you could add a Result type node for Zip files that looks like this:

<ResultType DisplayName="Zippy Results" Name="zippy">
  <Query>FileExtension='zip'</Query> 
  <PropertyRef Name="FileName" />
  <PropertyRef Name="Size" />
  <PropertyRef Name="Path" />
  <PropertyRef Name="Created" />
  <PropertyRef Name="Write" />
  <PropertyRef Name="CreatedBy" />
  <PropertyRef Name="ModifiedBy" /> 
</ResultType>

Now, not only can your users search specifically for Zip files, they won't be confused by being offered the option to search for "Comments" that don't exist.

The query node isn't restricted to just file extensions. You can set up a result type with virtually any query supported by the SharePoint Search engine. The "Documents" Result type, for example, simply uses the IsDocument property:

<Query>IsDocument=1</Query>

Summary

This article has given you an overview of the tremendous flexibility of the Advanced Search web part. You have learned about both the easy "checkbox" options and the not so straight-forward XML configuration file. You can now tailor Advanced Search to the specific languages, documents, and custom properties used in your environment.

 
Posted by Woody Windischman | 10 Comments | Trackback Url | Bookmark with:        
Tags: Administration, MOSS, Learning, Search, SharePoint

Links to this Post

Comments

Wednesday, 17 Sep 2008 06:43 by punit
how to hide the result type from the search

Wednesday, 17 Sep 2008 08:40 by Woody
Under the Scopes section in the tool pane, simply un-check the "Show the result type picker" box and apply the settings.

Wednesday, 17 Sep 2008 09:15 by punit
Thnx for the reply But if i un-check the result type picker then property picker also hide along with reslt type i want to hide only the result type not the property picker

Thursday, 18 Sep 2008 11:23 by Woody
I'm not sure exactly what you are asking. Do you mean that you do not want an existing type to be listed? Or do you want to create a result type that excludes certain results? (P.S. I've enabled comment moderation, so you won't see what you have posted until I have a chance to review it.)

Thursday, 18 Sep 2008 08:08 by punit
Thnx for the reply.My query is In the Advance search page there is one option of "Result Type" and after that one option of "Add property restriction" If i hide "Result type" option by un-checking "Show the result type picker" then it Automatically hides the "Add Property restriction"option also from the advance search page.I want to hide only the "Result Type" option.

Thursday, 18 Sep 2008 09:02 by Woody
I mentioned this a little in the article. The Property Restrictions available are derived from the Result Type selected. If you don't have any result types, you can't have a property restriction. What you might do is delete all of the result types except "All Results". While that won't suppress the drop-down, at least there won't be anything else in it to confuse your users.

Friday, 19 Sep 2008 08:59 by punit
Thnx for help it's works i have deleted all extra things from result type only all results is coming.

Friday, 3 Oct 2008 01:00 by Marie Wessels
hello! I have a custom list definition for contacts. I need to add a result type that only returns contacts. in the article, you say it is possible to add content types to the query. how would one do this? Is there a site that specifies valid queries? Thx for you time (and a great article :) ) Marie.

Friday, 3 Oct 2008 01:10 by Marie Wessels
Heh, found the content type restriction: ContentType='' But if there is a location where this sort of detail is specified that would be awesome.

Friday, 3 Oct 2008 05:23 by Woody
I'm glad you found what you needed. Some of the documentation is still a bit limited or confusing. Essentially, the properties allowed are pretty much the managed properties - the same as those permitted in any search query. These can vary based on your environment, but you can get a list of them from your SSP. If you have MSSX or the Infrastructure updates for MOSS, you can just select "Metadata Properties" from the quick launch on your search administration page. You can also find them at "{your SSP Host:port}/admin/_layouts/schema.aspx"

Name:
URL:
Email:
Comments:

CAPTCHA Image Validation