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
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