Hi all,
This is my first posting to this list. I am trying to figure out how to use
Lucy, using the instructions on this page:
http://incubator.apache.org/lucy/docs/perl/Lucy/Docs/Tutorial/BeyondSimple.html
I wrote the attached script, which works the first time I run it, but the
second time I run it, it gives me the following error:
---
rename from
'C:\Users\Desiletsa\Documents\eclipse_workspace\WeBiText\Spikes\lucy\schema.temp'
to
'C:\Users\Desiletsa\Documents\eclipse_workspace\WeBiText\Spikes\lucy\schema_1.json'
failed: File exists
lucy_Schema_write at
C:\Users\Desiletsa\AppData\Roaming\.cpanplus\5.12.3\build\Lucy-0.2.2\core\Lucy\Plan\Schema.c
line 410
at C:/Users/Desiletsa/Documents/eclipse_workspace/WeBiText/Spikes/try_Lucy.pl
line 32
---
If I delete the directory
C:/Users/Desiletsa/Documents/eclipse_workspace/WeBiText/Spikes/lucy, then I can
run the script again.
What am I doing wrong?
Thx.
Alain Désilets
use Lucy::Plan::Schema;
use Lucy::Plan::FullTextType;
use Lucy::Analysis::PolyAnalyzer;
use Lucy::Index::Indexer;
my $index_path = File::Spec->canonpath("./lucy");
# Create Schema.
my $schema = Lucy::Plan::Schema->new();
my $polyanalyzer = Lucy::Analysis::PolyAnalyzer->new(
language => 'en',
);
my $type = Lucy::Plan::FullTextType->new(
analyzer => $polyanalyzer,
);
$schema->spec_field( name => 'url', type => $type );
$schema->spec_field( name => 'language', type => $type );
$schema->spec_field( name => 'sentences', type => $type );
# Create Indexer.
my $indexer = Lucy::Index::Indexer->new(
index => $index_path,
schema => $schema,
create => 1,
truncate => 1,
);
my $sentences_as_string = "hello world at time=".time();
my $doc = {sentences => $sentences_as_string};
$indexer->add_doc($doc);
$indexer->commit();
# my $searcher = Lucy::Search::IndexSearcher->new(
# index => $index_path
# );
#my $query = "hello";
#my $hits = $searcher->hits(
# query => $query,
# offset => 0,
# num_wanted => 100,
# );
#
#my $hit_count = $hits->total_hits();
#
#print "-- for \$query='$query', \$hit_count=$hit_count\n";