[Xapian-discuss] Perl Search::Xapian
Olly Betts
olly at survex.com
Mon Jan 27 23:23:01 GMT 2014
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