Skip to main content.
home | support | download

Back to List Archive

Re: Sorting results by domain

From: koszalekopalek <koszalekopalek(at)not-real.interia.pl>
Date: Tue Jun 07 2005 - 15:22:39 GMT
Bill Moseley wrote:
> On Mon, Jun 06, 2005 at 05:28:12AM -0700, koszalekopalek wrote:
> 
>>I want swish-e to first return results from, say www.kormoran.net, and 
>>then from reksio.kormoran.net. How do I do it?
>>
>>My first idea is to create swishdomain property while indexing and then 
>>sort results by domain and by rank. Does it make sense?
> 
> 
> Yes, that's how I would do it.

[...]

Ok, thanks. This is what I did in case anyone finds it useful:

-------------------------------------------------------------------
1) In spider.cfg I added a call to add_swishserver in the filter_content 
callback routine:


sub add_swishserver
{
         my $pContent = $_[0];
         my $server = $_[1];
         my $meta = qq{<META NAME="swishserver" CONTENT="$server">};

         if ($$pContent =~ m/<HEAD>/i) {
                 $$pContent =~ s{<HEAD>}{<HEAD>$meta}i;
         } else {
                 $$pContent =~ s{<HTML>}{<HTML><HEAD>$meta</HEAD>}i;
         };
};


sub my_filter_content
{
         my $uri = $_[0];
         my $pContent = $_[3];

         # ...
         # ...

         # create swishserver property
         if ($uri->canonical =~ m{http://(\w+.kormoran.net)}i) {
                 add_swishserver ($pContent, $1);
         };
};

-------------------------------------------------------------------
2) Now the documents fed to swish have the following meta tag
inserted just after <HEAD>:

<META NAME="swishserver" CONTENT="www.kormoran.net">


-------------------------------------------------------------------
3) In the swish configuration file I added this:

PropertyNames swishserver

-------------------------------------------------------------------
4) In my CGI routine I can now use SetSort():


   $handle = SWISH::API->new ($db);

   $query = $handle->New_Search_Object;
   $query->SetSort ('swishserver desc swishrank');

   $results = $query->Execute($formWords);


A.

----------------------------------------------------------------------
Znajdz swoja milosc na wiosne... >>> http://link.interia.pl/f187a
Received on Tue Jun 7 08:22:42 2005