Marinos Yannikos
2010-Oct-24 23:42 UTC
[Xapian-discuss] Cannot index with dynamic spelling data (Perl/Search::Xapian)
This is my test case, what am I doing wrong? It seems that the API is used incorrectly, but I cannot find the problem... --- 8< --- #!/usr/bin/perl use Search::Xapian qw(:all); use strict; my $xa = new Search::Xapian::WritableDatabase ("/tmp/xapian", DB_CREATE_OR_OVERWRITE); my $indexer = Search::Xapian::TermGenerator->new(); $indexer->set_flags(Search::Xapian::FLAG_SPELLING); my $doc = new Search::Xapian::Document; $indexer->set_document($doc); $indexer->index_text("hello 123 blah blah"); $xa->add_document($doc); --- >8 --- Output: terminate called after throwing an instance of 'Xapian::InvalidOperationError' Aborted It works fine without "$indexer->set_flags(Search::Xapian::FLAG_SPELLING);", but then spelling correction does not work. The error/exception occurs at index_text(). I've tried with/without stemmer, it makes no difference. xapian-core version is 1.2.3, Search::Xapian is 1.2.3.0. Perl5.10 (Debian Lenny). Thanks, Marinos
Jim Lynch
2010-Oct-25 01:00 UTC
[Xapian-discuss] Cannot index with dynamic spelling data (Perl/Search::Xapian)
On 10/24/2010 07:42 PM, Marinos Yannikos wrote:> #!/usr/bin/perl > > use Search::Xapian qw(:all); > use strict; > > my $xa = new Search::Xapian::WritableDatabase ("/tmp/xapian", > DB_CREATE_OR_OVERWRITE); > > my $indexer = Search::Xapian::TermGenerator->new(); > $indexer->set_flags(Search::Xapian::FLAG_SPELLING); > > my $doc = new Search::Xapian::Document; > $indexer->set_document($doc); > $indexer->index_text("hello 123 blah blah"); > > $xa->add_document($doc);Try this: #!/usr/bin/perl use Search::Xapian qw(:all); use strict; my $xa = new Search::Xapian::WritableDatabase ("/tmp/xapian", DB_CREATE_OR_OVERWRITE); my $indexer = Search::Xapian::TermGenerator->new(); $indexer->set_database($xa); $indexer->set_flags(Search::Xapian::FLAG_SPELLING); my $doc = new Search::Xapian::Document; $indexer->set_document($doc); $indexer->index_text("hello 123 blah blah"); $xa->add_document($doc); I think it needs to know what database to do the spelling check on. Jim.