On Mon, 6 Jan 2003 Jeffrey.Grunstein@ny.frb.org wrote:
>
> Not quite.
>
> I want to display swishdescription if the match was found in
> swishdescription (the BODY tag in this case).
>
> But if the match was found somewhere else (let's say a KEYWORDS or
> DESCRIPTION meta tag), causing
> swishdescription not to be displayed, then display the META_DESCRIPTION tag
> INSTEAD OF the highlighted
> BODY tag.
>
> In other words, when the search results are displayed, if swishdescription
> is blank (it would be in the case I describe
> above), set swishdescription to the description meta tag and print that
> instead of what's stored by the STOREDESCRITION
> directive.
Hum, well I'm still not 100% clear. But I don't think that's the way the
script works. But it would not be that hard to make it do what you want
to do. You need a clear understanding of how the script works, though.
swish.cgi works like this:
The record display format is in three parts:
1) the title line that's a link
2) a description
3) additional properties that display as key: value data
This is not hard wired, but the general design works this way.
The parameters in swish.cgi allow you to say what properties each of those
are. Here's are the settings used for those three and their defaults:
title_property => 'swishtitle',
description_prop => 'swishdescription'
display_props => [qw/swishlastmodified swishdocsize swishdocpath/]
Hopefully that should be clear in the comments of swish.cgi.
Now, if you have metanames setup, you can search different fields.
metanames => [qw/swishdefault swishtitle swishdocpath /],
That will give you radio buttons to select where you want to search.
Now, for display purposes (really for highlighting purposes) you have to
map the metanames to property names -- they are not related as far as
swish-e knows, but the need to be related for the display.
That is, if you do a normal non-metaname search, you are searching in the
body and title -- so the highlighting code needs to know that there was a
hit in the swishdescription (body) and/or swishtitle (title) properties.
So there's this config setting:
meta_to_prop_map => {
swishdefault => [ qw/swishtitle swishdescription/ ],
swishtitle => [ qw/swishtitle/ ],
swishdocpath => [ qw/swishdocpath/ ],
all => [ qw/swishtitle swishdescription swishdocpath/ ],
},
So you can see a search in "swishdefault" means to highlight in the
swishtitle and/or swishdescription:
swishdefault => [ qw/swishtitle swishdescription/],
Now, what happens next depends on what highlighting backend module you are
using. Each result returned from swish-e is passed through the
highlighting code, and that code knows what metaname(s) were searched, and
then uses that meta_to_prop_map hash to highlight words in the *related*
properties. Some highlighting modules highlight all the words and shows
the entire description, some (like the default 'PhraseHighlight' module)
extracts out a few words on each side of a highlighted word.
'PhraseHighlight' will also only display the first 100 words of the
description if it was *not* what was being searched.
"Display" is the wrong word there. The displaying is left to the
templating code.
After swish-e has returned all the results, and the highlighting code has
filtered all the display properties, then the templating code decides how
to display the record.
Now, the current default setup for swish.cgi is to display the records in
that fixed format I described above. If you wanted a system where what
was displayed depends on what metanames were searched, then you will need
to write your own template module -- or maybe just add some logic to the
template if using Template-Toolkit.
To do that (and this is describe a little in the docs) you copy an
existing template module and edit it for your needs.
Again, if you are using Template-Toolkit you could proably do everything
right in the HTML template and not need to write any new perl code. TT is
a powerful temmplating system. Since we are talking about display issues
it really makes sense for the template to decide how to format the search
results.
If you are using the default 'TemplateDefault' template system then copy
the TemplateDefault.pm perl module an edit it as needed.
There's a module called TemplateDumper.pm that's purpose is to dump out
the data that swish.cgi passes to the templating modules -- this will show
you what data you can work with.
--
Bill Moseley moseley@hank.org