[Xapian-discuss] Perl Search::Xapian
Jon Bradley
weatchu at gmail.com
Mon Jan 27 23:50:13 GMT 2014
Thanks, that works fine now.
The script is almost at the end of the loop now
40 # my $idterm = "Q".$identifier;
41 my $idterm = join('',"Q",$identifier);
42 $doc->add_boolean_term($idterm);
43 $db->replace_document($idterm, $doc);
With this error:
~/dev/sandbox/Xapian-perl$ ./Index1-Xap.pl 100-objects-v1.csv db
Argument "Q1974-100" isn't numeric in subroutine entry at
./Index1-Xap.pl line 43, <$csv_fh> line 2.
I took out the dot concatinate, thinking a join would make the
variable a string but both the join and dot method give the same error
in this case.
Sorry about the other error, you are right. This error I checked does
match the code.
(\ /)
( . .) Jon's website is here:
c(")(") http://www.securityrabbit.com
On Mon, Jan 27, 2014 at 2:23 PM, Olly Betts <olly at survex.com> wrote:
> On Mon, Jan 27, 2014 at 02:05:54PM -0900, Jon Bradley wrote:
>> ~/dev/sandbox/Xapian-perl$ ./Index1-Xap.pl 100-objects-v1.csv db
>> "db" is not exported by the Search::Xapian module
>> Can't continue after import errors at ./Index1-Xap.pl line 7.
>> BEGIN failed--compilation aborted at ./Index1-Xap.pl line 7.
>
> This error doesn't seem to correspond to the script you sent.
>
>> What I did was try to convert the python example code in to Perl.
>> There's probably other errors, but my question is how to I deal with
>> the :db DB_CREATE_OR_OPEN in perl? Been reading a lot and
>> my understanding of perl I guess is not the best it seems, any
>> help would be great, Thanks.
>>
>> ----------------snip---------------
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>> unless ($#ARGV eq 1) { die "Usage: <cvsfile> <dbpath>\n" };
>>
>> use Search::Xapian;
>> use Tie::Handle::CSV;
>>
>> my $csvfile = $ARGV[0];
>> my $dbpath = $ARGV[1];
>> my $db = Search::Xapian::WritableDatabase->new(
>> path => $dbpath,
>> mode => "DB_CREATE_OR_OPEN",
>> );
>
> The Perl bindings don't use this named parameter style - just pass
> parameters like this:
>
> my $db = Search::Xapian::WritableDatabase->new($dbpath, DB_CREATE_OR_OPEN);
>
> But you'll also need to specify you want these constants at "use" time:
>
> use Search::Xapian (':db');
>
> Or ':all' for all the constants.
>
> There's an example indexer here:
>
> http://trac.xapian.org/browser/svn/trunk/xapian-bindings/perl/docs/examples/simpleindex.pl
>
> Cheers,
> Olly
More information about the Xapian-discuss
mailing list