--- trunk/Estraier.pm 2006/01/06 13:19:50 51 +++ trunk/Estraier.pm 2006/01/06 14:10:29 52 @@ -1172,7 +1172,96 @@ croak "cond mush be Search::Estraier::Condition, not '$cond->isa'" unless ($cond->isa('Search::Estraier::Condition')); croak "depth needs number, not '$depth'" unless ($depth =~ m/^\d+$/); + my $resbody; + my $rv = $self->shuttle_url( $self->{url} . '/search', + 'text/x-estraier-draft', + $self->cond_to_query( $cond ), + \$resbody, + ); + return if ($rv != 200); + + my (@docs, $hints); + + my @lines = split(/\n/, $resbody); + return unless (@lines); + + my $border = $lines[0]; + my $isend = 0; + my $lnum = 1; + + while ( $lnum <= $#lines ) { + my $line = $lines[$lnum]; + $lnum++; + + #warn "## $line\n"; + if ($line && $line =~ m/^\Q$border\E(:END)*$/) { + $isend = $1; + last; + } + + if ($line =~ /\t/) { + my ($k,$v) = split(/\t/, $line, 2); + $hints->{$k} = $v; + } + } + + my $snum = $lnum; + + while( ! $isend && $lnum <= $#lines ) { + my $line = $lines[$lnum]; + $lnum++; + + if ($line && $line =~ m/^\Q$border\E/) { + if ($lnum > $snum) { + my $rdattrs; + my $rdvector; + my $rdsnippet; + + my $rlnum = $snum; + while ($rlnum < $lnum - 1 ) { + #my $rdline = $self->_s($lines[$rlnum]); + my $rdline = $lines[$rlnum]; + $rlnum++; + last unless ($rdline); + if ($rdline =~ /^%/) { + $rdvector = $1 if ($rdline =~ /^%VECTOR\t(.+)$/); + } else { + $rdattrs->{$1} = {$2} if ($line =~ /^(.+)=(.+)$/); + } + } + while($rlnum < $lnum - 1) { + my $rdline = $lines[$rlnum]; + $rlnum++; + $rdsnippet .= "$rdline\n"; + } + if (my $rduri = $rdattrs->{'@uri'}) { + push @docs, new Search::Estraier::ResultDocument( + uri => $rduri, + attrs => $rdattrs, + snippet => $rdsnippet, + keywords => $rdvector, + ); + } + } + $snum = $lnum; + #warn "### $line\n"; + $isend = 1 if ($line =~ /:END$/); + } + + if (! $isend) { + warn "received result doesn't have :END\n$resbody"; + return; + } + } + + if (! $isend) { + warn "received result doesn't have :END\n$resbody"; + return; + } + + + return new Search::Estraier::NodeResult( docs => \@docs, hints => $hints ); } @@ -1228,7 +1317,7 @@ This is method which uses C to communicate with Hyper Estraier node master. - my $rv = shuttle_url( $url, $content_type, \$req_body, \$resbody ); + my $rv = shuttle_url( $url, $content_type, $req_body, \$resbody ); C<$resheads> and C<$resbody> booleans controll if response headers and/or response body will be saved within object.