Author image Marvin Humphrey
and 1 contributors

NAME

KinoSearch::Highlight::Highlighter - Create and highlight excerpts.

SYNOPSIS

    my $highlighter = KinoSearch::Highlight::Highlighter->new(
        fields  => ['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(
        fields         => ['content'], # required
        excerpt_length => 150,         # default: 200
        formatter      => $formatter,  # default: SimpleHTMLFormatter
        encoder        => $encoder,    # default: SimpleHTMLEncoder
    );

Constructor. Takes hash-style parameters:

  • fields - the names of the fields from which to draw excerpts. Each field in the list must be spec'd as vectorized.

  • excerpt_length - the maximum length of each excerpt, in characters.

  • formatter - an object which subclasses KinoSearch::Highlight::Formatter, used to perform the actual highlighting.

  • encoder - an object which subclasses KinoSearch::Highlight::Encoder. All excerpt text gets passed through the encoder, including highlighted terms. By default, this is a SimpleHTMLEncoder, which encodes HTML entities.

COPYRIGHT

Copyright 2005-2007 Marvin Humphrey

LICENSE, DISCLAIMER, BUGS, etc.

See KinoSearch version 0.20.