summaryrefslogtreecommitdiff
blob: 542ec029e4f58d0185e95883171a054e43353936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;