Summary: Some correctly spelled search terms show incorrect or inappropriate "Did you mean..." suggestions.
Fix: Modify front-end XSLT code to hide "Did you mean..." suggestions for correctly spelled or inappropriate words.
Example: You would like to block all suggestions containing "paper."
Suggestion displayed for correctly spelled "newspaper" word:
Did you mean: news paper
To exclude selected words from "Did you mean..." spelling suggestions, perform the following steps:
- Open Search > Search Features > Front Ends.
- Next to the front end you want to modify, click Edit.
- Under XSLT Stylesheet Editor, click Edit underlying XSLT code.
- Find
<xsl:template name="spelling">
- Modify the following "if" condition:
<!-- **********************************************************************
Spelling suggestions in result page (do not customize)
********************************************************************** -->
<xsl:template name="spelling">
<xsl:if test="/GSP/Spelling/Suggestion">
<p><span class="p"><font color="{$spelling_text_color}">
<xsl:value-of select="$spelling_text"/>
<xsl:call-template name="nbsp"/>
</font></span>
<xsl:variable name="apps_param">
<xsl:choose>
<xsl:when test="/GSP/PARAM[@name='exclude_apps']">
<xsl:text disable-output-escaping='yes'>&exclude_apps=</xsl:text>
<xsl:value-of select="/GSP/PARAM[@name='exclude_apps']/@original_value" />
</xsl:when>
<xsl:when test="/GSP/PARAM[@name='only_apps']">
<xsl:text disable-output-escaping='yes'>&only_apps=</xsl:text>
<xsl:value-of select="/GSP/PARAM[@name='only_apps']/@original_value" />
</xsl:when>
</xsl:choose>
</xsl:variable>
<a ctype="spell"
href="{$gsa_search_root_path_prefix}?q={/GSP/Spelling/Suggestion[1]/@qe}&spell=1&{$synonym_url}{$apps_param}">
<xsl:value-of disable-output-escaping="yes" select="/GSP/Spelling/Suggestion[1]"/>
</a>
</p>
</xsl:if>
</xsl:template>You need to add additional "and" condition to disable spelling suggestion for "paper":
<xsl:if test="/GSP/Spelling/Suggestion and not(contains(/GSP/Spelling/Suggestion[1]/@q,'paper'))">
That should filter and disable incorrect spelling suggestion. If you need to exclude multiple words, they should be add as follow:
<xsl:if test="/GSP/Spelling/Suggestion and not(contains(/GSP/Spelling/Suggestion[1]/@q,'selected_term1') and
not(contains(/GSP/Spelling/Suggestion[1]/@q,'selected_term2') and
not(contains(/GSP/Spelling/Suggestion[1]/@q,'selected_term3'))"> - Click Save
- Verify that "Did you mean" does not display for filtered words:
Additional Information: You can disable "Did you mean..." suggestions completely. See "Did you mean" text has incorrect spelling for more information about disabling spelling suggestions.
Versions affected: 7.2, 7.4 releases