#!/usr/bin/perl -w use strict; use Search::Estraier 0.06; use parse_trivia; # score for words in title my $title_rank = 3; open(my $t, "gzip -cd trivia.list.gz |") || die "can't open trivia.list.gz: $!"; # open node my $node = Search::Estraier::Node->new( url => 'http://localhost:1978/node/trivia', user => 'admin', passwd => 'admin', create => 1, ); my $nr = 1; my $max = 0; # no limit parse_trivia($t, sub { my $a = {@_}; # create a document object my $doc = Search::Estraier::Document->new; # add attributes to the document object $doc->add_attr('@uri', "file://localhost/trivia/$nr"); $doc->add_attr('@title', $a->{title}); $doc->add_hidden_text( (($a->{title} . ' ') x $title_rank) ); $doc->add_attr('@size', length($a->{trivia})); $doc->add_attr('year', $a->{year}) if ($a->{year}); foreach my $q ( $a->{qv} ) { $q = join(' ', @$q) if (ref($q) eq 'ARRAY'); next unless ($q); $doc->add_attr('quote', $q); $doc->add_hidden_text($q); } # add the body text to the document object $doc->add_text($a->{trivia}); # register the document object to the database $node->put_doc($doc); $nr++; last if ($max && $nr > $max); });