[KinoSearch] Simple->create_excerpt (was: Subclassable Highlighter)

Father Chrysostomos sprout at cpan.org
Wed Jan 30 17:53:09 PST 2008


On Jan 30, 2008, at 5:18 PM, Marvin Humphrey wrote:

> Another possibility is to add an "excerpt_field" param to  
> Simple::search, and automatically inserts an "excerpt" member into  
> the Doc.
>
>   $simple->search(
>      query         => 'foo bar',
>      excerpt_field => 'body',
>   );
>   while ( my $hit = $simple->fetch_hit ) {
>      print qq|
>         <p>
>            <strong>$hit->{title}</strong><br />
>            $hit->{excerpt}
>         </p>
>         |;
>   }
>
> I'm not really enthused about either of those, because Simple's  
> methods should always resemble the related behaviors of regular KS  
> as closely as possible.

How about making excerpt_field part of the constructor? Then we have  
this:

   my $simple = KinoSearch::Simple->new(
      path => '/path/to/index',
      language => 'en',
      excerpt_field => 'body',
   );
   $simple->search(
      query         => 'foo bar',
   );
   while ( my $hit = $simple->fetch_hit ) {
      print qq|
         <p>
            <strong>$hit->{title}</strong><br />
            | . $simple->create_excerpt . qq|
         </p>
         |;
   }

But I suppose this is starting to become KinoSearch::NotSoSimple, so  
maybe we should forget about it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rectangular.com/pipermail/kinosearch/attachments/20080130/19a988ea/attachment-0003.htm 
-------------- next part --------------
_______________________________________________
KinoSearch mailing list
KinoSearch at rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch


More information about the kinosearch mailing list