The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

KinoSearch::Highlight::Highlighter - create and highlight excerpts

SYNOPSIS

    my $highlighter = KinoSearch::Highlight::Highlighter->new(
        excerpt_field  => 'bodytext',
    );
    $hits->create_excerpts( highlighter => $highlighter );

DESCRIPTION

KinoSearch's Highlighter can be used to select a relevant snippet from a document, and to surround search terms with highlighting tags. It handles both stems and phrases correctly and efficiently, using special-purpose data generated at index-time.

METHODS

new

    my $highlighter = KinoSearch::Highlight::Highlighter->new(
        excerpt_field  => 'bodytext', # required
        excerpt_length => 150,        # default: 200
        pre_tag        => '*',        # default: '<strong>'
        post_tag       => '*',        # default: '</strong>',
    );

Constructor. Takes hash-style parameters:

  • excerpt_field - the name of the field from which to draw the excerpt.

  • excerpt_length - the length of the excerpt, in bytes. This should probably use characters as a unit instead of bytes, and the behavior is likely to change in the future.

  • pre_tag - a string which will be inserted immediately prior to any keyword in the excerpt, typically to accentuate it. If you don't want highlighting, set both pre_tag and post_tag to ''.

  • post_tag - a string which will be inserted immediately after any keyword in the excerpt.

COPYRIGHT

Copyright 2005-2006 Marvin Humphrey

LICENSE, DISCLAIMER, BUGS, etc.

See KinoSearch version 0.07.