Tony Bowden via RT wrote:
Show quoted text> On Fri, Jan 20, 2006 at 08:05:23AM -0500, via RT wrote:
>> As described in
>>
http://www.kasei.com/pipermail/plucene/2005-September/000618.html,
>> TermInfosWriter.pm has a bug with the use of xor on bitstrings. As one
>> of the arguments may be numeric, the whole expression is numeric.
>> The solution (also described on that page) is to explicitly stringify
>> both arguments to force bitstring xor.
>> Replace line 134:
>> ($text ^ $self->{last_term}->text) =~ /^(\0*)/;
>> With these two lines:
>> my $last_term_text = $self->{last_term}_text;
>> ("$text" ^ "$last_term_text") =~ /^(\0*)/;
>> or variant thereof.
>
> I'm happy to accept a patch like this if someone can put together a
> failing test case.
Here you are. I can see that it's debatable whether or not this is a bug in
Plucene -- the documentation does state that the second argument to the
Plucene::Document::Field methods should be a string, and not a number.
However, in the spirit of Perl's general DWIMitude it's probably a good idea
if Plucene does the conversion (or, at the very least, warns the user when
the ::Field is created, instead of when the document is added).
N
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 1;;
use Test::Warn;
use Plucene::Document;
use Plucene::Document::Field;
use Plucene::Analysis::SimpleAnalyzer;
use Plucene::Index::Writer;
my $analyzer = Plucene::Analysis::SimpleAnalyzer->new();
my $writer = Plucene::Index::Writer->new('/tmp/index', $analyzer, 1);
my $doc = Plucene::Document->new();
# If this line is left as is, it triggers a warning. If the number is
# stringified by quoting then it doesn't trigger the warning.
$doc->add(Plucene::Document::Field->Keyword('revision', 1));
warning_is { $writer->add_document($doc); } undef,
q{Numeric fields don't trigger warnings};