Subject: | SegmentReader::doc_freq can return undef. |
Perl 5.8.4
Linux atlantis 2.4.28-vs1.29 #1 Di Nov 30 10:40:17 CET 2004 i686 GNU/Linux
When I make a query, I sometimes get a log(0) runtime error:
Debugger excerpt:
Plucene::Search::Similarity::idf(/usr/share/perl5/Plucene/Search/Similarity.pm:60):
60: my ($x, $y) = ($docs->doc_freq($tf), $docs->max_doc);
DB<4> v
57
58 sub idf {
59: my ($self, $tf, $docs) = @_;
60==> my ($x, $y) = ($docs->doc_freq($tf), $docs->max_doc);
61: return 1 + log($y / (1 + $x));
62 }
63
64 =head2 coord
65 66
DB<4> x
0 0
DB<5> x $self
0 'Plucene::Search::Similarity'
DB<6> x $tf
0 Plucene::Index::Term=HASH(0x8bf0a8c)
'field' => 'content'
'text' => 'greate'
DB<7> x $docs
0 Plucene::Search::IndexSearcher=HASH(0x8be1e5c)
'reader' => Plucene::Index::SegmentsReader=HASH(0x8b67abc)
'directory' => 'name'
'max_doc' => 0
'readers' => ARRAY(0x87688e4)
empty array
'writelock' => undef
DB<8> n
Plucene::Search::Similarity::idf(/usr/share/perl5/Plucene/Search/Similarity.pm:61):
61: return 1 + log($y / (1 + $x));
DB<12> x $x
0 undef
I suspect that the index is empty at this point (I have added two docs with a writer prior to this query, but the writer has not yet been closed).