This is a nasty one if you want to use search to get publishing content displayed somewhere.
The short version
Here’s the short version if you’re not interested in the full monty:
On an article page, you can set an image in a field of the type “Publishing Image”. If you want to display this image in the search results, you’d expect you can use the “ows_PublishingPageImage” property to map in a managed property. Well, this won’t work. Microsoft Support doesn’t call it a bug (“SharePoint cannot crawl the content of a compound control”)and suggests, as a workaround, to store the ImageUrl value in another field using an event handler and then to map this field in a managed property.
Background
The problem first showed at a customer where article pages created in one site collection should be show in another. The configuration of the farm is like the following:
Note: this only conceptually reflects the infrastructure.
In Site collection 1, there is a site with a pages library. In this page library, pages with the content type Article Page (standard MOSS content type and page layout) are created for news.
Article created in the page library on Site collection 1 should be shown in Site collection 2 (without content deployment). As there is a boundary between site collections, the search index is used to make content from site collection available in the other. All users have at least read rights on all site collections.
Using either the default Search Core Results web part or a third party web part, it proved impossible to show the page image and roll up image in Site collection 2. The title and page content were shown without problems.
The next section shows repro steps taken.
Repro steps
For reproducing the problem, only one site collection is required as it will show the problem as well.
In the site collection, use a page library to store the Welcome or Article pages (both can be used for this scenario).
Each page has at least the following fields filled:
- page content --> stored in the field “Page Content” (internal name: PublishingPageContent)
- image --> stored in the field “Page Image” (internal name: PublishingPageImage)
- roll up image --> stored in the field “Rollup Image” (internal name: PublishingRollupImage)
The images are displayed on the page by the standard Publishing Image control in the page layout (out of the box). The images are stored in an image library in Site collection 1. For testing purposes, images of both the default created image library “/PublishingImages/” and a newly created image library called “Pictures” (/Pictures) were used.
Below is a screenshot of the page properties of the page used for testing:
The page used for testing was published as a major version.
After that, the index was run with an incremental crawl. When searching for the word “welcome”, the Search Center displays the results correctly:
What I want to achieve now, is to show the Page Image (field: PublishingPageImage) instead of the icon. At my customer, I’m using a third party web part to display the articles, but the concept can be shown by using only standard functionality.
To make this possible, a few steps need to be followed:
- create a managed property mapping to the page field
- run a full crawl on the index
- change the Core Results web part settings to include the new managed property as a column
- change the XSLT for the search result to render an image using the new column
Step 1
In the SSP, I created a managed property called PublishingPageImage. This property maps to the indexed field ows_PublishingPageImage:
Note: the name of the managed property should match the mapped property as closely as possible to avoid problems.
Step 2
To make this managed property usable, a full crawl should be done. After the full crawl, you can already see the problem:
There are no items found using this property. However, as you can see in the page properties (first screen shot under Repro steps), the field does have a value!
Conclusion: the field ows_PublishingPageImage is not indexed properly!
Step 3
Steps 3 and 4 are actually obsolete as step 2 already shows us no content will be returned. However, to get the picture, I’ll show them anyway.
In the site collection Search Center, go to edit mode and go to the properties of the web part Search Core Results. Under Results Query Options, Selected Columns, open the columns editor and add
<Column Name="PublishingPageImage"/>
This will ensure our new managed property can actually be used in the search results. Click OK to close the editor dialog.
Step 4
In the web part property pane, click the XSL Editor button. In the editor, search for
<span class="srch-Icon">
<a href="{$url}" id="{concat('CSR_IMG_',$id)}" title="{$url}">
<img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" />
</a>
</span>
This text displays the default icon
.
What I want to achieve is that the publishing page image is shown, when available. To do so, replace the xsl text above with something like the following:
<xsl:if test=” publishingpageimage != ‘’”>
<img>
<xsl:attribute name=”src”>
<xsl:value-of select="publishingpageimage"/>
</xsl:attribute>
</img>
</xsl:if>
<xsl:if test=” publishingpageimage = ‘’”>
<span class="srch-Icon">
<a href="{$url}" id="{concat('CSR_IMG_',$id)}" title="{$url}">
<img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" />
</a>
</span>
</xsl:if>
Note: as step 2 already makes sure we don’t get any results, it’s not sure if the creating an <img> is necessary. If the field stores complete html , the following would be OK:
<xsl:if test=” publishingpageimage != ‘’”>
<xsl:value-of select="publishingpageimage"/>
</xsl:if>
<xsl:if test=” publishingpageimage = ‘’”>
<span class="srch-Icon">
<a href="{$url}" id="{concat('CSR_IMG_',$id)}" title="{$url}">
<img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" />
</a>
</span>
</xsl:if>
Click OK, and Apply. Click OK on the web part tool pane to close it.
The expected result would be that the image of the page is shown in the results
Other information
Please note that the images themselves (as library items) can be found with the search. The problem is the page field, creating the link between the page and the image. It looks like this field is not indexed properly, making it impossible to show images related to an article via Search.
Please note that if we use an out of the box picture field (not the publishing image), the contents are stored and indexed. However, this is not the behavior we want as we want to use the publishing features, not the WSS types.
Solution from Microsoft
For this problem, I opened a support case that ran for ages. After almost a year (!) mailing back and forth, I got the following solution:
Dear Sjoert,
As agreed your existing support case SRQ[…] will now be archived. Customer Satisfaction is very important to us and we would like to be sure that you are very satisfied with the service you have received.
If I can be of any further assistance on this case or if you have any suggestions for improving our service please do not hesitate to contact myself or my manager […] so we can ensure you receive our immediate attention.
Here is a summary of your case:
[ARCR]
ACTION:
You want to customize Search results Page, so that found pages are listed with an Image which is stored in the Web Part "Page Image".
You mapped the ows_PublishingPageImage with the internal name "PublishingPageImage" of the web part "Page image".
You also customized the web part "Search Core Results", so that the query returns also the mapped property "ows_PublishingPageImage" and modified the XSLT of this web part, so that it should additionally display the "PublishingpageImage" as a picture left of the url of the page.
RESULT:
The Image in the "Page Image" of the found page is not displayed in the Search Core results web part.
CAUSE:
The mapped property "ows_PublishingPageImage" is not crawled in that way, that we can use it as an image blob. SharePoint cannot crawl the content of a compound control.
RESOLUTION:
Workaround: You need to add the url to the image to the Pages Library List. We used the column "comment" for that purpose. We provided an EventHandler which receives and handles the events "ItemUpdating" and "ItemAdding" events(executed if you change or add a picture to the picture library).
public override void ItemUpdated(SPItemEventProperties properties)
{
SPListItem item = properties.ListItem;
string imageUrl = ((Microsoft.SharePoint.Publishing.Fields.ImageFieldValue)(item["PublishingPageImage"])).ImageUrl;
item["Comments"] = imageUrl;
item.Update();
}
Use this picture library for adding picture to the web parts "Page Image" or "Rollup Image".
Run a full crawl. Map the meta property ows_Comment to the column "Comment". Run a crawl again. Used this property name in the Search results Core Web Part in the query options and modify the XSLT.
Conclusion
I still think this is a bug: SharePoint cannot crawl the content of a compound control. However, there’s a workaround. I suggest not to use the Comments field as suggested by Microsoft but a dedicated field instead.