NAME
KinoSearch::Highlight::Highlighter - Create and highlight excerpts.
SYNOPSIS
my $highlighter = KinoSearch::Highlight::Highlighter->new;
$highlighter->add_spec( field => 'body' );
$hits->create_excerpts( highlighter => $highlighter );
DESCRIPTION
KinoSearch's Highlighter can be used to select relevant snippets 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;
Constructor. Takes no arguments.
add_spec
$highlighter->add_spec(
field => 'content', # required
excerpt_length => 150, # default: 200
formatter => $formatter, # default: SimpleHTMLFormatter
encoder => $encoder, # default: SimpleHTMLEncoder
name => 'blurb' # default: value of field param
);
Add a spec for a single highlighted excerpt. Takes hash-style parameters:
field - the name of the field from which to draw the excerpt. The field must be
vectorized
(which is the default -- see FieldSpec).excerpt_length - the maximum length of the excerpt, in characters.
formatter - an object which isa KinoSearch::Highlight::Formatter. Used to perform the actual highlighting.
encoder - an object which isa KinoSearch::Highlight::Encoder. All excerpt text gets passed through the encoder, including highlighted terms. By default, this is a SimpleHTMLEncoder, which encodes HTML entities.
name - the key which will identify the excerpt in the excerpts hash. Multiple excerpts with different specifications can be created from the same source field using different values for
name
.
COPYRIGHT
Copyright 2005-2007 Marvin Humphrey
LICENSE, DISCLAIMER, BUGS, etc.
See KinoSearch version 0.20.