In SharePoint, if we want to perform a search within a predefined scope then we can go for two out-of-the box web parts. One is the search box web part and the other one is search core results web part. The search box web part contains a dropdown and a textbox .The dropdown contains the value of the search scopes and the textbox is for entering the search keyword. The search core results web part is to display the search results.
To define a new scope go to the site settings of your root site, then in the site collection administration section click on the search scope,here you can see the search scopes present in the display groups. Here you can add a new scope by clicking the New Scope. You can also add a new scope from your SSP(Sharepoint Service Provider) present in the Central Administration.
Now, to show the search results in the search core results web part we need to set the properties “Target search results page URL” of the search box web part .To set these properties go to Site Actions -> Edit Page -> Modify Shared Web part (of search box) -> Miscellaneous. ,then provide the value for the properties( the value will be the URL of the page where the search core results web part is present).
Now let’s say, you have defined a search scope “Test Scope” which is pointing to a list (Test List) .This search will be performed on the list items .When you perform a search , the results will show the link of the item and only few fields values which contains the serach keyword.
But If you want to see the details of the list item fields value in a proper format, then the first thing is to get the value of the list item columns within the search core result web part.
Step -1 :
To make this column value available in the search core result web part we need to add the “Managed Properties” in the “Metadata Property Mappings”. To add the Managed Properties Go to the
Central Administration => SSP => Search Setting s => Metadata property mappings => New Managed Property => Provide the Property Name => Select the Type(The type will be similar to the list column type) => Click on Add Mappings => Select the column from the crawled property (Column name will have a prefix ows_ColumnName) => ok.
Step – 2 :
Now go to the search core result web part page then Click on Site Actions => Edit page = > Modify Shared Web part => Go to the Result Query Options => Click on the Selected Columns , then add the field within the columns tag .
Step – 3 :
Now open the XSL Editor and replace with the following code.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
Now click SAVE => APPLY => OK . Then copy the content showing in the search core result web part and save it as a XML file .
Step – 4 :
Now open the SharePoint designer insert DataFormWebpart in a page . Now in the “Data Source Library “ Task Pane go the “XML Files” section click on the “Add an XML file” and add the XML file.
Now click on the XML file ,then select the “Show Data” . Now select the columns which you want to show in search result page(Here you can see the columns which we had added in the Metadata property). Now click on the “Insert selected Field as” and select the view . Now you can format the columns in whatever way you want (By modifying the XSLT of the DataFormWebPart).
Step – 5 :
Then copy the codes present between the <xsl:stylesheet> </xsl:stylesheet> tag in the DataFormWebPart . Now open the XSL Editor of the Search Core Results web part and replace the code present between the <xsl:stylesheet> </xsl:stylesheet> tag ‘s with the copied content .
Now you will see the search results will be in similar format which you have defined in the DataFormWebpart.