Configuring Search Scopes to Roll up Data Across Site Collections

First we create the content source and Crawl Rules. From Here

From Manage Service Applications click on Search Service Application and then click Manage on the ribbon. Under Crawling, click Content Sources, New Content Source. Enter Name, choose Content source type as SharePoint Sites, enter address of sites For Crawl Settings choose “Only crawl the Site Collection of each start address”. Set Crawl schedule to your liking. Now in Quick Launch add a crawl rule  for this content source to your needs.

Then create a scope

From the Quick Launch click on Scopes, click on New Scope, enter title and Use the default Search Results Page. Now add rules to new Scope item, by hovering, click Edit Properties and Rues, new rule, select Property Query and pick content type = Issues to get all issues returned, click ok. If the Content Type property is not in Property Restrictions list, then on the left quick launch click on Meta Data Properties, find Content Types, hover and change to show in scopes. Then you have to restart a full crawl to test, go to Content sources, hover and start new crawl.

Configure the search core results Web Part

Edit a page and add the Search Core Results Web Part. Edit Web Part and expand Results Query Options. Set the Cross-Web Part query ID to User query, enter the Fixed Keyword Query to point to our new custom search scope e.g. ContentType=Issues.  In the Append Text To Query field put in values that will be used as the default query. Leaving it blank will return all results that meet the criteria of our custom search scope. Enter syntax as Field Name:Value such as AssignedTo:”Jim Cox” or Priority:”2″ You can put both together with a space between to query the results by both AssignedTO and Priority. Not sure how to do an or.

In Fetched Properties section, modify fetched properties field to add in our fields to show in results. We want to be able to show the assigned to and the current task status in our results. So we add
<Column Name=”BPStatusWorkItem”/>  <Column Name=”AssignedTo”/>   at the end of the line but inside of the </Columns> tag. This is easy to do just copy and paste the last column and change name to match internal name of Field. Now we need to change the XSL to display them, click the XSL editor button in the display properties section and add the fields to the match=”Result” xsl:template.

Custom code and XSLT changes to make it look and feel like a list

Get a sample of xml from your test web part where results are returned, we will use it in SP Designer so we can visually see our data as we make a nice looking list. Add this to the web part xslt and it will return xml of our results.

<?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="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>

Save the xml to a file and use as a data source. In SPD insert an empty Data View Web Part and choose data source as our xml file above. Add some fields and get some results showing in list view.

Advertisements