After a basic introduction let’s see, how you can build a custom search page, and Property mappings. This post will built on traditional method without Infrastructure Updates, but in the next part we’ll see the Updates details as well.
Step 0: Set the basic search
See my previous post and practice the details described there.
Step 1: Create lists and libraries
In my example, we’ll use the following scenario: the site collection contains several lists and document libraries, that are responsibe for question-type items, and answer-type items. Of course, these items are connected into question-answers pairs. The main goal is to build a custom “Search for Questions and Answers” (“Kérdések és Válaszok keresése”) page.
So, what do we have to do being able to build this page? First of all, the “backend”-structure: content types and lists, with indexed columns. After that we nees property mappings. Finally: build this Search page and customize some XSLTs. Let’s see what does it mean.
Step 2: Search scope settings
Basically we need the basic content types: Question and Answers. In the lists we use them instead of Item, so we can define custom search scopes based on them: One scope is for Questions, and the other is for Answers. Oops, but by default we cannot use Content Type in the scopes. Don’t worry, just go to the Search settings on Shared Services Administration page, and open Metadata Property Mappings. Here you can find the “Content Type” property – open it, and check the “Allow this property to be used in scopes” box in. Then you can use it in your scopes:
Well, currently we have lists with our content types, and scopes that can be used for searching Questions and Answers. So we can use them on my custom search page as well (see Step 4).
Step 3: Set the Property mapping
Of course, our content types contains custom fields as well. For example Program, Document Type, Construction, Keyword, etc. These fields have to be able to search on our custom page, so we should set them as indexed columns in every related list.
After that, we have to set these fields as searchable properties. Go to the Metadata Propery Mappings page again, and choose New Managed Property option. Add a name to this mapped property (for example, Program), and optionally a description. Select the type (Text), and click Add Mappings button – here you can search for the required field, in this example Program:
OK, let’s map it! We’re ready to build the full Search page now.
Step 4: Create custom Search page
First of all, create a custom advanced search page: content type choosing and property searching.
For using Question and Answer content types, you have to define a new scope display group. Go to your site collection’s administration page, and shoose Search Scopes option. Here you can define a new Display Group (Questions and Answers – Kérdések és Válaszok), and add your content types to it.
After that, go back to your custom search page, and modify the properties of the Advanced Search Box, and change the Display Group to Questions and Answers:
The result: on your page you can choose your content types instead of the default ones.
OK, we’re almost ready. Almost. We have to set the property search as well. We have indexed fields and mapped properties, so let’s edit the Properties’ XSLT. Search the PropertyDefs tag, and add your properties one by one as PropertyDef nodes:
<PropertyDefs> <PropertyDef Name="Program" DataType="text" DisplayName="Program" /> <PropertyDef Name="DocumentType" DataType="text" DisplayName="Dokumentumtípus" /> <PropertyDef Name="Construction" DataType="text" DisplayName="Konstrukció" /> </PropertyDefs>
After PropertyDefs, you can find a node named ResultTypes. In this you can define what kind of properties do you want to use on your search page:
<ResultTypes> <ResultType DisplayName="Minden eredmény" Name="default"> <PropertyRef Name="Program" /> <PropertyRef Name="Dokumentumtípus"/> <PropertyRef Name="Konstrukció" /> </ResultType> </ResultTypes>
Finally save the Advanced Search Box web part, and let’s try your brand new Search Page. Persuasive, isn’t it?…