Go Back

Removing Navigation from Search Results

Sitefinity CMS Search - Based on Lucene Sitefinity CMS comes included with a powerful Lucene-based search engine.  Using Sitefinity, new search indexes can quickly be created.  Once the index is in place, search boxes & results can be easily dragged & dropped onto any Sitefinity page.

However, by default Sitefinity will index the entire contents of a page.  This includes elements that exist on all pages such as navigation, headers, footers, etc.  These site-wide elements can impact the search results and pollute the snippets associated with each of the search results.

Removing Unwanted Content from Search Indexes

Each time a new search index is created, Sitefinity creates a new new ~/App_Code/Search/[SearchIndex-Name] folder.  Inside this folder is a fieldsInfoProvider.xml file.  This file defines the content that gets indexed, ignored or emphasized. 

Sitefinity identifies content sections by matching HTML tags.  These HTML section are defined in the fieldsInfoProvider.xml file.  Here is some example HTML for a web page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Example Page</title>
</head>
<body>
        <div id="hd">
            Header logo & links
        </div>
        <div id="menu">
            Site navigation & menu
        </div>
        <div id="bd">
            Body content of the page
        </div>
        <div id="ft">
            Footer navigation & links.
        </div>
</body>
</html>

In the example above, only the body content is relevant for search results.  The other content is site-wide and can be ignored.  To ignore this content, add the following fields to the fieldsInfoProvider.xml file:

~/App_Data/Search/[SearchIndexName]/fieldsInfoProvider.xml:

<?xml version="1.0" encoding="utf-8"?>
<fields>
  <field name="header" weight="-1" indexAttribute="" filterTag="div" filterAttributes="id:hd" />
  <field name="menu" weight="-1" indexAttribute="" filterTag="div" filterAttributes="id:menu" />
  <field name="footer" weight="-1" indexAttribute="" filterTag="div" filterAttributes="id:ft" />
</fields>
  • filterTag – the HTML tag Sitefinity should match
  • filterAttributes - specific HTML tag properties & values Sitefinity should match.
  • weight – the emphasis Sitefinity should put on content matched (-1 is zero emphasis)

For More Information

Sitefinity gives you complete control over how your search results display.  For additional, check out the Working with Sitefinity Search Webinar [notes].

Comments  2

Post a comment!
  1. Formatting options
       
     
     
     
     
       
  2. I'm sorry for the CAPTCHA. You have spammers to thank for this: