Skip to main content.
home | support | download

Back to List Archive

Re: Ordering Swish.cgi Search Results by swishdocpath

From: Peter Karman <peter(at)not-real.peknet.com>
Date: Thu Nov 03 2005 - 02:32:33 GMT
Jon Sorensen scribbled on 10/31/05 8:47 AM:

> I am indexing a number of sites into a single index (spider conf below).
> I need to have one of these servers, 'meriter.staywellsolutionsonline.com',
> to show up last in the results for swish.cgi except when sorted by
> swishdocpath
> from the search form. Would separating this out into antother index solve
> this problem?

In order to adjust the sorting, you need a property to sort on. Since you want 
to sort by URL, but not alphabetically, I'd suggest adding some kind of <meta> 
tag (.e.g, meriter) as you index, just to the files you want to sort last, and 
then change your swish.cgi code to sort by that property first unless sorted by 
swishdocpath.

I haven't tested any of this code, but this might get you pointed in the right 
direction.

Example swish config:

   PropertyNames meriter

Example content filter callback for spider.pl:

my %serverC = (
         base_url    => 'http://meriter.staywellsolutionsonline.com',
         same_hosts  => [ qw/meriter.staywellsolutionsonline.com/ ],
         email       => 'nobody@nowhere.com',
   keep_alive  => 1,
      test_url    => sub {
          my $uri = shift;
             return 0 if $uri->path =~ /EmailForm\.pg/;
             return 0 if $uri->path =~ /PrinterFriendly\=true/;
             return 0 if $uri->path =~ /RelatedItems/;
             return 1;
          },
   filter_content => sub {
        my $content_ref = $_[3];
        $$content_ref =~ s,</head>,<meta name='meriter' content='1' /></head>,i;
        return 1;
        },
   use_md5  => 1,
);



Example mod to swish.cgi config:


   sorts => [qw/ meriter swishrank swishlastmodified swishtitle swishdocpath/],


and then the logic to change the sort based on if the current sort is by 
swishdocpath (around line 1507 in set_sort_order() ):



   my $sortby = $q->param('sort') || '';
   if ( $sortby eq 'swishdocpath' ) {

      shift @$sorts_array; # assumes that 'meriter' is first item in array

   }


good luck,
pek



-- 
Peter Karman  .  http://peknet.com/  .  peter(at)not-real.peknet.com
Received on Wed Nov 2 18:32:57 2005