Created
January 19, 2012 16:18
-
-
Save andrewrjones/1640933 to your computer and use it in GitHub Desktop.
Dump the KinoSearch1 index.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use KinoSearch1::Index::IndexReader; | |
my $r = KinoSearch1::Index::IndexReader->new( invindex => '/path/to/index' ); | |
# get one or more readers | |
my @readers = ref $r->{sub_readers} eq 'ARRAY' ? @{ $r->{sub_readers} } : $r; | |
for my $reader (@readers) { | |
print "Segment " | |
. $reader->get_seg_name . " has " | |
. $reader->max_doc | |
. " docs\n"; | |
# the index is numbered from 0 to max_doc, so just loop | |
# through them and get the documents | |
for(my $i = 0; $i < $reader->max_doc; $i ++){ | |
# A KinoSearch1::Document::Doc object | |
my $doc = $reader->fetch_doc($i); | |
# this will depend on how your index has been set up | |
my $title = $doc->get_value('title'); | |
print "$title\n"; | |
} | |
} | |
print "Total documents: " . $r->max_doc . " in " . @readers . " segments\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment