diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2008-03-20 17:41:03 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2008-03-21 20:13:06 -0700 |
commit | 85766ce726d1971d8c49d351007a03be6010f101 (patch) | |
tree | f4ac06fad14d445a46b5283c4906f0be5e274b0e /index-dumper.pl | |
parent | Add index creation script. (diff) | |
download | distindex-85766ce726d1971d8c49d351007a03be6010f101.tar.gz distindex-85766ce726d1971d8c49d351007a03be6010f101.tar.bz2 distindex-85766ce726d1971d8c49d351007a03be6010f101.zip |
Add tools to query and dump the index.
Diffstat (limited to 'index-dumper.pl')
-rw-r--r-- | index-dumper.pl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/index-dumper.pl b/index-dumper.pl new file mode 100644 index 0000000..542ec02 --- /dev/null +++ b/index-dumper.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# Lucene stuff by Robin H. Johnson <robbat2@gentoo.org> + +use Lucene; +use Data::Dumper; + +my $store = Lucene::Store::FSDirectory->getDirectory("data", 0); +my $reader = Lucene::Index::IndexReader->open($store); + +# get number of docs in index +my $num_docs = $reader->numDocs(); + +for(my $i=0;$i<$num_docs; $i++) { + # get the nth document + my $doc = $reader->document($i); + # This is missing in the Perl bindings :-( + #my $fields = $doc->fields; + # So we have to either specify a field directly + my $fields = $doc->get('md5'); + my $s = $doc->toString; + print $s."\n"; +} + +$reader->close; +undef $reader; |