Mailing List Archive

r3794 - trunk/perl/lib/KinoSearch/Docs/Tutorial
Author: creamyg
Date: 2008-08-29 14:13:37 -0700 (Fri, 29 Aug 2008)
New Revision: 3794

Modified:
trunk/perl/lib/KinoSearch/Docs/Tutorial/Highlighter.pod
Log:
Flesh out the Highlighter tutorial chapter.


Modified: trunk/perl/lib/KinoSearch/Docs/Tutorial/Highlighter.pod
===================================================================
--- trunk/perl/lib/KinoSearch/Docs/Tutorial/Highlighter.pod 2008-08-29 20:32:22 UTC (rev 3793)
+++ trunk/perl/lib/KinoSearch/Docs/Tutorial/Highlighter.pod 2008-08-29 21:13:37 UTC (rev 3794)
@@ -5,8 +5,41 @@

=head1 DESCRIPTION

-TODO
+Adding relevant excerpts with highlighted search terms to your search results
+display makes it much easier to scan and assess which hits look promising,
+radically improving the end user experience.

+To add highlighting and excerpting to the search.cgi sample app via
+L<KinoSearch::Highlight::Highlighter>, create a C<$highlighter> object outside
+the hits iterating loop...
+
+ my $highlighter = KinoSearch::Highlight::Highlighter->new(
+ searchable => $searcher,
+ query => $q,
+ field => 'content'
+ );
+
+... then modify the loop and the per-hit display to generate and include the
+excerpt.
+
+ # Create result list.
+ my $report = '';
+ while ( my $hit = $hits->next ) {
+ my $score = sprintf( "%0.3f", $hit->get_score );
+ my $title = encode_entities( $hit->{title} );
+ my $excerpt = $highlighter->create_excerpt($hit);
+ $report .= qq|
+ <p>
+ <a href="$hit->{url}"><strong>$title</strong></a>
+ <em>$score</em>
+ <br />
+ $excerpt
+ <br />
+ <span class="excerptURL">$hit->{url}</span>
+ </p>
+ |;
+ }
+
=head1 COPYRIGHT

Copyright 2008 Marvin Humphrey


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits