Skip to main content.
home | support | download

Back to List Archive

Returning Highlighted Text or the META Description

From: <Jeffrey.Grunstein(at)not-real.ny.frb.org>
Date: Fri Jan 03 2003 - 18:27:43 GMT
I'm running Swish-E 2.2.2 on Solaris 9.  I am running the swish.cgi that
comes with the distribution.
When I index, I define metaname properties for the DESCRIPTION and KEYWORDS
meta tags.

When swish.cgi returns results, I want it to display the highlighted BODY
text (I'm storing BODY tags
as descriptions).  But if the match was found somewhere other than in
swishdefault, no description
is returned since the match was elsewhere (in the DESCRIPTION tag, for
example).

I want to modify swish.cgi to return the DESCRIPTION tag in this case.
Here's what I have so far but
it's not working.  Am I on the right path?  Is there an easier way to do
it?   I'd appreciate any help.

--------------------------------------------------------------------------------

My code snippet from swish.cgi, in run_swish():

           # Now do any formatting
            if ( $highlight ) {
                if ( !$highlight_object ) {
                    my $package = $highlight->{package} ||
'DefaultHighlight';

                    eval { require "$package.pm" };
                    if ( $@ ) {
                        $self->errstr( "Failed to load Highlighting Module
- check error log" );
                        warn "$0: $@";
                        $highlight = '';
                        next;
                    } else {
                        $highlight_object = $package->new( $self,
$self->{metaname} );
                    }
                }

                # Highlight any fields, as needed
                $highlight_object->highlight( \%h  );

                next;
            }


            # Trim down the description if no highlight, or if highlighting
some other property
            # Not very nice.  The highlighting code would limit by words

            if ( $trim_prop && $h{$trim_prop} ) {
                my $max = $conf->{max_chars} || 500;

                if ( length $h{$trim_prop} > $max ) {
                    $h{$trim_prop} = substr( $h{$trim_prop}, 0, $max) . '
<b>...</b>';
                }
            }

     # MY CODE HERE...
            # If swishdescription is blank, set it to the META description
tag...
            if (! $h{$trim_prop}) {
                $h{$trim_prop} = $properties{description};
            }

            next;
Received on Fri Jan 3 18:27:55 2003