Skip to main content.
home | support | download

Back to List Archive

Re: SetSearchLimit and -L

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Tue Feb 08 2005 - 17:09:35 GMT
On Tue, Feb 08, 2005 at 01:14:20AM -0800, SSchattenberg@iht.com wrote:
> 
> Sorry for the vague-ness and thank you for your help.
> 
> When I use SetSearchLimit in my cgi, like this:
> 
>       my $low = "2005-01-11";
>       my $high = "2005-01-14";
>       $search->SetSearchLimit("publicationdate", $low, $high);
> 
> It does not limit the search.

Show me!  I can help quickly if you provide something I can try.  Just
saying it doesn't work means that it's too much effort for me to try
it right away.  I had forgotten about your original question already.

Here's a few more tips:

http://swish-e.org/docs/install.html#when_posting_please_provide_the_following_information_

Here's an example of something anyone could try and would show the
problem:

-------------------8<----------------------------------------
$ cat dates.pl
#!/usr/bin/perl
use warnings;
use strict;
use SWISH::API;

build_index();

my $swish = SWISH::API->new('index.swish-e');
my $s = $swish->New_Search_Object;
if ( @ARGV ) {
    warn "setting range @ARGV\n";
    $s->SetSearchLimit( 'swishtitle', @ARGV );
}
$swish->AbortLastError if $swish->Error;

$s->SetSort('swishtitle');
my $results = $s->Execute('not dkdkdkdk');
while ( my $r = $results->NextResult ) {
    print $r->Property( 'swishtitle' ), "\n";
}


sub build_index {
    open SWISH, '|swish-e -S prog -i stdin -v0' or die $!;

    for my $day ( 1..30 ) {
        my $d = sprintf('%02d', $day );
        my $doc = <<EOF;
<html>
<head>
<title>2005-01-$d</title>
</head>
<body>
hi
</body>
</html>
EOF

        my $len = length $doc;
        print SWISH "Path-Name: Day-$d.txt\nContent-Length: $len\n\n", $doc;
    }

    close SWISH or die $!;
}
---------------------------------------------->8------------------------

$ perl dates.pl
2005-01-01
2005-01-02
2005-01-03
2005-01-04
2005-01-05
2005-01-06
2005-01-07
2005-01-08
2005-01-09
2005-01-10
2005-01-11
2005-01-12
2005-01-13
2005-01-14
2005-01-15
2005-01-16
2005-01-17
2005-01-18
2005-01-19
2005-01-20
2005-01-21
2005-01-22
2005-01-23
2005-01-24
2005-01-25
2005-01-26
2005-01-27
2005-01-28
2005-01-29
2005-01-30

$ perl dates.pl  2005-01-04 2005-01-12
setting range 2005-01-04 2005-01-12
2005-01-04
2005-01-05
2005-01-06
2005-01-07
2005-01-08
2005-01-09
2005-01-10
2005-01-11
2005-01-12

So that seems to work.  Maybe it's due to a problem with the version
you are running.  I only tested with my cvs copy.




-- 
Bill Moseley
moseley@hank.org

Unsubscribe from or help with the swish-e list: 
   http://swish-e.org/Discussion/

Help with Swish-e:
   http://swish-e.org/current/docs
   swish-e@sunsite.berkeley.edu
Received on Tue Feb 8 09:09:38 2005