3. Advanced Search Pages
The Advanced Search page contains the single Advanced Search Web Part shown in its default configuration in Figure 8.
Although much of this Web Part can be customized
easily in the property dialog box, three critical portions require
modifying XML. The following information and illustrations will walk you
through the properties to be modified as they appear. To edit the
Advanced Search Web Part, first place the page in edit mode from either
the Site Actions menu or the Page Ribbon. Then, to the upper right of
the Web Part, choose Edit Web Part from the drop-down menu.
The first section of the Advanced Search Web Part is shown in Figure 9.
These search box options enable the user to construct complex queries
without knowing the appropriate query language structure. Each option
includes a text label box and a selection to enable it.
The Scope section, displayed in Figure 10,
presents a series of query filters with check boxes and label text
boxes. Although the Display Group used by the scope picker is configured
within this section, both the Language and Result Type pickers are
controlled by an XML section that will be discussed later.
The Properties section, shown in Figure 11,
manages query filters that use managed properties. An XML string
contained in the Properties text box controls the managed properties
available for use here, as well as the languages exposed in the language
picker and the file types defined in the result type picker.
To edit this code, place the cursor in the text box
to expose the Builder text editor blue button to the right of the text
box. Because the file is a single line in this editor, you may want to
copy the entire text to your favorite XML editor, make changes, and
paste the modified text back into the Builder for saving to the Web Part
properties.
The first section of the XML defines the languages supported by search.
For each language definition (LangDef), the display name is shown
within quotation marks and the assigned language ID is also shown within
quotation marks. You do not need to modify this portion. Following is
just a small portion of the code as an example.
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<LangDefs>
<LangDef DisplayName="Simplified Chinese" LangID="zh-cn" />
<LangDef DisplayName="Traditional Chinese" LangID="zh-tw" />
<LangDef DisplayName="English" LangID="en" />
<LangDef DisplayName="Finnish" LangID="fi" />
<LangDef DisplayName="French" LangID="fr" />
<LangDef DisplayName="German" LangID="de" />
<LangDef DisplayName="Italian" LangID="it" />
<LangDef DisplayName="Japanese" LangID="ja" />
<LangDef DisplayName="Spanish" LangID="es" />
</LangDefs>
The next section specifies the languages by LangID to
be displayed in the language picker, as shown in the following code
sample. To change the languages displayed, simply add or remove lines
from these default settings and save the code back to the Properties
text box.
<Languages>
<Language LangRef="en" />
<Language LangRef="fr" />
<Language LangRef="de" />
<Language LangRef="ja" />
<Language LangRef="zh-cn" />
<Language LangRef="es" />
<Language LangRef="zh-tw" />
</Languages>
The next portion is the Property Definition section,
as shown in the following code block. These properties must be managed
properties. Additional property entries must include the real managed
property name, the data type, and the name to display in the Web Part.
<PropertyDefs>
<PropertyDef Name="Path" DataType="text" DisplayName="URL" />
<PropertyDef Name="Size" DataType="integer" DisplayName="Size (bytes)" />
<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="CreatedBy" DataType="text" DisplayName="Created By" />
<PropertyDef Name="ModifiedBy" DataType="text" DisplayName="Last Modified By" />
</PropertyDefs>
You can add managed properties to these definitions
even if they have not been designated for use in a scope. After they are
defined, these properties can then be used in the result types filter
definitions as well as the managed properties filters.
<ResultType DisplayName="Word Documents" Name="worddocuments">
<KeywordQuery>FileExtension="doc" OR FileExtension="docx" OR
FileExtension="dot" OR FileExtension="docm" OR
ileExtension="odt"</KeywordQuery>
<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="Write" />
<PropertyRef Name="CreatedBy" />
<PropertyRef Name="ModifiedBy" />
<PropertyRef Name="Title" />
</ResultType>
There are result types for the following categories.
You can enter new managed properties as property
definitions, and then create new result types or modify existing ones in
this file. After you edit the string, save it back into the Property
text box.
The Miscellaneous section contains a single setting for the target results URL, as shown in Figure 12.
In particular, a custom Advanced Query Web Part might need to point to a
custom results page where the presentation of the results Web Parts has
been modified to meet business needs. This custom results page can also
contain non-search Web Parts that connect to the search Web Parts.
A sample search query constructed by the advance search Web Part can be passed as the following.
ALL(searchterm) (DetectedLanguage="en") (IsDocument="True") Write>=02/01/2010
A knowledgeable user can enter the search in a basic query box as the following and achieve the same results.
searchterm DetectedLanguage="en" IsDocument="True" Write>=02/01/2010
However, most users will find the UI of the advanced search easier to use.