KinoSearch::Highlight::Highlighter - Create and highlight excerpts.
my $highlighter = KinoSearch::Highlight::Highlighter->new; $highlighter->add_spec( field => 'body' ); $hits->create_excerpts( highlighter => $highlighter );
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.
my $highlighter = KinoSearch::Highlight::Highlighter->new;
Constructor. Takes no arguments.
$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).
vectorized
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.
name
Copyright 2005-2007 Marvin Humphrey
See KinoSearch version 0.20.
To install KinoSearch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm KinoSearch
CPAN shell
perl -MCPAN -e shell install KinoSearch
For more information on module installation, please visit the detailed CPAN module installation guide.