-->

Thursday 12 January 2012

Get XML data from the CoreResultsWebPart

We often want to debug the XSLT code that we have written for our CoreResultsWebPart, this post will help you to extract the data from the CoreResultsWebPart and later which we can apply to debug our custom XSLT written for the CoreResultsWebPart.

Prerequisites

1. You need to have the Administrator privileges
2. Basic understanding of creating web applications and running the FAST search.

TODO

First thing you need to do is get the Basic Fast Search Center site up and running. Below i have mentioned the brief steps.
1. Create Web application with classic mode authentication.
2. Create a root site collection with "Fast Search Center" template.
3. Open the root site collection and try to search, as long as it displays the result you are fine :)

First Step : Edit the page and replace the default XSL with our custom XSL

As you Site is up and running, search for any term and go to the results page. Edit the page from Site Actions -> Edit Page
Search for the Search Core Results web part on the page and edit the web part. In the search core results editor pane, go to the Core Results->Display properties.

Uncheck the "Use Location Visualization" option, by default it would be checked.
Note: It means that site has to use the columns and XSL defined at the federated location level. Which is shared by all the search sites in the farm. When we uncheck this option we can define our own XSL format. More information on this topic can be found here
 
On unchecking this option the area under Fetched Properties and XSL editor will be enabled.
Fetched Properties are the columns that you want to be retrieved from the FAST search database. The columns mentioned within these properties will only be fetched.

Now click on the XSL editor button, it will open the dialog displaying the XSL used for the CoreResultsWebpart. Replace the default XSLT with the following code. Don't forget to take the backup of default code in case you want to revert back to original 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"/>
<xsl:template match="/">
<xsl:copy-of select="*"/>
</xsl:template>
</xsl:stylesheet>

 Click on Ok and save the page. 

Second Step : View the Search Results Web part XML data

Right-click the page zone that contains the Search Results Web Part that you want to view the search results XML data for, and then click View Source on the pop-up menu. This opens a page in Notepad that contains the HTML source. 


Search for the string “<All_Results>”. This is the opening tag for the section that contains the full search results set for the Web Part you modified.





No comments:

Post a Comment