Home > Fluid Dynamics Search Engine > Help > 1174

Customizing HTML: Highlighting keywords in the search result listing

This help file provides more detail on how FDSE highlights matching keywords in the search result listings. Below is an example of a result listing; this feature covers making the search keyword "example" bold in two places in the listing:

Search Results
Your search for example found the following documents (of 1 documents searched):
Displaying documents 1-1 of 1, with best matches first:

1. Examples of Highlighting
This file contains several examples of how the search highlighting works.
URL: http://local.xav.com/example.html - 1KB - 11 Feb 2003
Excerpt: yellow bold highlighting example highlighting yellow bold follow...

Note that the "Excerpt" field appears if and only if the "Show Examples" feature is enabled. For more information on that feature, see How to show examples of keyword matches in the search result listings.

Frequently Asked Questions

Q. How can I change the style of highlighting? What if I want red text or no bolding?

A. The document description highlighting uses a bold tag with class "hl1" (that's H L one). The highlighting in the optional excerpt section uses class "hl2". To change the highlighting, just edit those class definitions in the FDSE stylesheet file "search/searchdata/templates/style.inc". If you have customized the layout to use your own stylesheet, then add the class definitions to your stylesheet and customize them there.

Examples of customized class definitions:

// example: removes bolding; effectively disables highlighting
.hl1,.hl2 {
	font-weight:none;
	}

// example: adds red background
.hl1,.hl2 {
	background-color:#ff8888;
	}

// example: adds red background to description keywords, yellow to examples
.hl1 {
	background-color:#ff8888;
	}
.hl2 {
	background-color:yellow;
	}

Here is a rendering based on the final customized classes:

1. Examples of Highlighting
This file contains several examples of how the search highlighting works.
URL: http://local.xav.com/example.html - 1KB - 11 Feb 2003
Excerpt: yellow bold highlighting example highlighting yellow bold follow...

Note that web browsers that do not support stylesheets, such as Netscape 3, will always see the keywords in bold, no matter how you customize the styles.


Q. Can I highlight keywords in the title or URL fields?

A. No. Support for that may be added in some future release.


Q. Why are some keywords not highlighted, even though they appear? Why are some things highlighted that shouldn't be?

A. The algorithm that FDSE uses to match search keywords with documents is different than the algorithm used for selecting keyword highlights in description and excerpt fields.

In particular, by default FDSE will only match whole words when calculating relevance. For highlighting, however, FDSE will select substrings of whole words. In addition, the keyword highlighting may fail for phrases or words containing accented characters, even though they match for relevance.

Some people feel that this discrepancy makes the keyword highlighting less than helpful. If you feel that way, you can disable it entirely using the customized classes given in the first example above.


    "Customizing HTML: Highlighting keywords in the search result listing"
    http://www.xav.com/scripts/search/help/1174.html