Hi I am using Plucene::Index::Writer; for creating the index.
The code is give below how I am creating indexes
print "Content-type:text/html \n\n";
use CGI::Carp qw( fatalsToBrowser );
use Plucene;
use DBI;
use Data::Dumper;
use Plucene::Document;
use Plucene::Document::Field;
use Plucene::Analysis::SimpleAnalyzer;
use Plucene::Index::Writer;
my $analyzer = Plucene::Analysis::SimpleAnalyzer->new();
my $writer = Plucene::Index::Writer->new("doc_index", $analyzer,1);
#database creation
my $dbh=DBI->connect('dbi:mysql:username','DB','Password',{RaiseError => 1,AutoCommit => 0}) || die "Database connection not made: $DBI::errstr";
$SQL = "SELECT a,b,c,d,e,f,g,h,i,j,k from tablename;";
$st = $dbh->prepare($SQL) or die "Preparing MySQL query failed: $DBI::errstr";
$st->execute() or die "The execution of the MySQL query failed: $DBI::errstr";
while ($row = $st->fetchrow_hashref())
{
my $doc = Plucene::Document->new;
$doc->add(Plucene::Document::Field->Text(a => $row->{a} || 'NUll'));
$doc->add(Plucene::Document::Field->Text(b => $row->{b} || 'Null'));
$doc->add(Plucene::Document::Field->Text(c => $row->{c} || 'Null'));
$doc->add(Plucene::Document::Field->Text(d => $row->{d} || 'Null'));
$doc->add(Plucene::Document::Field->Text(e => $row->{e} || 'Null'));
$doc->add(Plucene::Document::Field->Text(f => $row->{f} || 'Null'));
$doc->add(Plucene::Document::Field->Text(g => $row->{g} || 'Null'));
$writer->add_document($doc);
#writing document to the doc_index folder
print Dumper($doc);
}
This way I am creating the index when i move into "doc_index" i.e in index directory
I got files something like _1110.f1
_1110.f2 _1110.f3 _1110.f4 _1110.fdt _1110.fdx _1110.fnm
_1110.frq _1110.prx _1110.tii _1110.tis
now if my database is update how i will link it to my plucene index.
or if I want to update something or delete something how can i tackel it with Plucene::Simple please suggest.
how could i know the $id $plucy->delete_document($id); form the plucene::simple
Please suggest
| [reply] |
Hi
After lot of brainstroming we decide to switch to solr search insted of plucene
| [reply] |