Skip to main content.
home | support | download

Back to List Archive

Re: Returning Highlighted Text or the META Description

From: Bill Moseley <moseley(at)>
Date: Mon Jan 06 2003 - 21:57:50 GMT
On Mon, 6 Jan 2003 wrote:

> OK, thanks.  I am working with a copy of that I had
> already customized to do other things.  I am usng PhraseHighlighting.
> Below is part of my show_result() function from TemplateDefault.
> I try reading in all the metanames using this line: my $metanames
> = $results->config('metanames');

Well, you are going outside the normal usage of the script -- there are
not methods defined for the data you want so you need to access the object

What you need to find out is what metaname was searched, right?

   $searched_meta = $results->{metaname};

That's just a hash lookup on the object, not a method call.  That's the
part you are missing, I beleive.

Then map that meta name to the related property or properties.  I didn't
test this but you might be able to do

   my $meta_map = $results->config('highlight')->{meta_to_prop_map};
   my $prop_array_ref = $meta_map->{$search_meta} | [ 'swishdescription'];

or you can just maintain your own has to map the metanames to properties
and not bother reading the hash from the swish.cgi config file.  That's up
to you.

Then when displaying your results you just display the property (or
properties) that were searched.

      display_descriptoin( $this_result, $_ ) for @$prop_array_ref;

where display_description() is your own function.

> but I get an error, about "Global symbol "%metanames" requires explicit
> package name at ..."

Well, that's just a common perl error.  You have to define your variables.

Bill Moseley
Received on Mon Jan 6 21:58:01 2003