This article shows two options to change the look of search results in WebSphere Portal Server 8 search center. The first one is the display of search results and the second one is the search term reloationship.
To display the search results in different formats, the following files in the Search Center Portlet application need to be modified.
This result.xsl file is used to process the search result atom feed. The default results are displayed similar to the one below. The standard columns are Relevance, Icon, Title, Person, and Date.
The default result.xsl controls the display format. To customize the display to suit your organization needs, the display table section inside the result.xsl needs to be modified. Use the Extensible Stylesheet Language to modify the table section of the result.xsl, the search result display can be changed to the one shown below.
In this case, only two columns are used in the table. The first column displays the file type and the second column display the title. Attached is the snippet of the modified result.xsl. When the result document is coming from the WCM content, the default icon is shown in the first column. When the result is a file, the first column shows the file extension based on the mime type. The titles for those files are coming from the first part of the summary field and are shown in the second column of the result table.
<td width="2%">
<xsl:choose>
<xsl:when test="substring-after(atom:link/@type,'/') = 'html'">
<img width="16" height="16" border="0" align="middle">
<xsl:attribute name="src">
<xsl:value-of select="$serverPath"/><xsl:value-of select="atom:link[@rel='icon']/@href"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="atom:category/@label"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="atom:category/@label"/>
</xsl:attribute>
</img>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="substring-after(atom:link/@type,'/') = 'pdf'">[PDF]</xsl:when>
<xsl:when test="substring-after(atom:link/@type,'/') = 'vnd.ms-excel'">[XLS] </xsl:when>
<xsl:when test="substring-after(atom:link/@type,'/') = 'vnd.openxmlformats-officedocument.wordprocessingml.document'">[DOCX]</xsl:when>
<xsl:when test="substring-after(atom:link/@type,'/') = 'msword'">[DOC] </xsl:when>
<xsl:when test="substring-after(atom:link/@type,'/') = 'plain'">[TXT] </xsl:when>
<xsl:when test="substring-after(atom:link/@type,'/') = 'txt'">[TXT] </xsl:when>
<xsl:when test="substring-after(atom:link/@type,'/') = 'zip'">[ZIP] </xsl:when>
<xsl:when test="substring-after(atom:link/@type,'/') = 'csv'">[CSV] </xsl:when>
<xsl:otherwise>[FILE]</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</td>
<td width="98%">
<h4>
<a class="entryURL" href="{concat($serverPath, atom:link[(@rel='alternate') or not(@rel)]/@href)}">
<xsl:attribute name="type">
<xsl:value-of select='atom:link/@type' />
</xsl:attribute>
<span style="display: none">
<span>
<xsl:value-of select="wplc:field[@id='contentSourceType']"/>
</span>
<span>
<xsl:value-of select="wplc:field[@id='PortletWindowId']"/>
</span>
<span>
<xsl:value-of select="wplc:field[@id='NavigationNode']"/>
</span>
<span>
<xsl:choose>
<xsl:when test="substring-after(atom:link/@type,'/') = 'html'">
<xsl:value-of select="atom:title" disable-output-escaping="yes" />
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(substring-after(atom:summary,'/Strong> ')) > 0">
<xsl:choose>
<xsl:when test="string-length(substring-after(atom:summary,'/Strong> ')) < 70">
<xsl:value-of select="substring(substring-after(atom:summary,'/Strong> '),1,string-length(substring-after(atom:summary,'/Strong> ')))" disable-output-escaping="yes" />...
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(substring-after(atom:summary,'/Strong> '),1,70)" disable-output-escaping="yes" />...
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="atom:title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</span>
<span>
<xsl:value-of select="atom:id"/>
</span>
</span>
<xsl:choose>
<xsl:when test="substring-after(atom:link/@type,'/') = 'html'">
<xsl:value-of select="atom:title" disable-output-escaping="yes" />
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(substring-after(atom:summary,'/Strong> ')) > 0">
<xsl:choose>
<xsl:when test="string-length(substring-after(atom:summary,'/Strong> ')) < 70">
<xsl:value-of select="substring(substring-after(atom:summary,'/Strong> '),1,string-length(substring-after(atom:summary,'/Strong> ')))" disable-output-escaping="yes" />...
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(substring-after(atom:summary,'/Strong> '),1,70)" disable-output-escaping="yes" />...
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="atom:title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</a>
</h4>
<div class="preFormatted lotusDetails"><xsl:value-of select="atom:summary" disable-output-escaping="yes" /></div>
<div>
<a class="tagWidgetLink" href="javascript:;" style="display: none;"><xsl:value-of select="$editKeywords"/></a>
<xsl:if test="wplc:field/@id='tag'">
<span class="lotusDivider" style="display: none;">|</span>
<span class="lotusTags"><xsl:value-of select="$tags"/> 
<xsl:for-each select="wplc:field">
<xsl:if test="@id='tag'">
<span class="tagLink"><xsl:value-of select='text()'/></span>
<xsl:if test="position() != last()"><span>, </span></xsl:if>
</xsl:if>
</xsl:for-each>
</span>
</xsl:if>
</div>
</td>
In WebSphere Portal 8 search center, the default search logic for the entry is the “OR” logic. To change the search logic to the “AND” relationship, the properties in the search collection configuration have to the modified. After the crawler finish running for the first time, do the following steps.
2) Search for the search collection configuration file. There should be one configuration file for each collection. The name is in this format
where *** is some a sequence of generated alphanumeric numbers. The files could likely in the directory /apps/SCE/search/config/
4) Save the changes to all configuration files.
5) Restart the remote search servers only.