Mailing List Archive

please help with Util::SortExternal
Hello all,

I have the following code now. First I must say that I can only use the 0.15 version of KinoSearch on my production environment.
My Problem is now that I want sort my search results by a date. I read in the mailinglist that some people use for this the SortExternal module.
Is it possible to use a sortsub with this module ? Because It has no effect now.

Thanks,

Felix

my $analyzer = KinoSearch::Analysis::PolyAnalyzer->new( language => 'en' );
my $searcher = KinoSearch::Searcher->new(
invindex => './kino_search_test/',
analyzer => $analyzer,
);

my $hits = $searcher->search(
query => $ARGV[0]
);

my $invindex = KinoSearch::Store::FSInvIndex->new(
path => './kino_search_test/',
create => 0
);
my $sortscheme =
my $sortex = KinoSearch::Util::SortExternal->new(
mem_threshold => 2,
invindex => $invindex,
seg_name => '_1',
sortsub => sub { substr($Sort::External::b,0,8) <=> substr($Sort::External::a,0,8) };
);

while ( my $hit = $hits->fetch_hit_hashref ) {
$sortex->feed(sprintf("%s|%s", $hit->{story_date},$hit->{story_title},) );
}
$sortex->sort_all();
while (my $sorted_line = $sortex->fetch) {
print "-".$sorted_line."\n";
};
--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
please help with Util::SortExternal [ In reply to ]
On May 16, 2007, at 12:52 AM, Felix Wittmann wrote:

> First I must say that I can only use the 0.15 version of KinoSearch
> on my production environment.

Is that because of the unstable API of the beta releases, or because
the beta releases don't compile? (They won't with Windows using
MSVC. That will change but it hasn't been top priority.)

> My Problem is now that I want sort my search results by a date.

There are some ugly hacks that let you do that in 0.15, but they're
not scalable.

> I read in the mailinglist that some people use for this the
> SortExternal module.

You can't use KinoSearch::Util::SortExternal for this. It has no
public API, and that's not what it's there for in any case. The
purpose of the SortExternal module is to sort lists which are too big
to fit in memory all at once; it's only used during indexing.
<http://en.wikipedia.org/wiki/External_sort>

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/