Search-Xapian-1.2.25.5/0000755000175000017500000000000014207007026013105 5ustar ollyollySearch-Xapian-1.2.25.5/MANIFEST0000644000175000017500000000635314207007026014245 0ustar ollyollyMANIFEST This list of files MANIFEST.SKIP README Changes Makefile.PL makehtmldocs typemap typemap-errorclasses perlobject.map Xapian/BM25Weight.pm Xapian/BoolWeight.pm Xapian/Database.pm Xapian/Document.pm Xapian/Enquire.pm Xapian/ESetIterator.pm Xapian/ESet.pm Xapian/MatchSpy.pm Xapian/MSetIterator.pm Xapian/MSet.pm Xapian/MSet/Tied.pm Xapian/MultiValueSorter.pm Xapian.pm Xapian/PerlStopper.pm Xapian/PositionIterator.pm Xapian/PostingIterator.pm Xapian/QueryParser.pm Xapian/Query.pm Xapian/RSet.pm Xapian/Stem.pm Xapian/SimpleStopper.pm Xapian/Stopper.pm Xapian/TermGenerator.pm Xapian/TermIterator.pm Xapian/TradWeight.pm Xapian/ValueCountMatchSpy.pm Xapian/ValueIterator.pm Xapian/Weight.pm Xapian/WritableDatabase.pm Xapian.xs XS/BM25Weight.xs XS/BoolWeight.xs XS/Database.xs XS/Document.xs XS/Enquire.xs XS/ESetIterator.xs XS/ESet.xs XS/MatchSpy.xs XS/MSetIterator.xs XS/MSet.xs XS/MultiValueSorter.xs XS/PositionIterator.xs XS/PostingIterator.xs XS/QueryParser.xs XS/Query.xs XS/RSet.xs XS/SimpleStopper.xs XS/Stem.xs XS/Stopper.xs XS/TermGenerator.xs XS/TermIterator.xs XS/TradWeight.xs XS/ValueCountMatchSpy.xs XS/ValueIterator.xs XS/Weight.xs XS/WritableDatabase.xs XS/DateValueRangeProcessor.xs XS/NumberValueRangeProcessor.xs XS/StringValueRangeProcessor.xs exception_data.pm generate-perl-exceptions Xapian/AssertionError.pm Xapian/DatabaseClosedError.pm Xapian/DatabaseCorruptError.pm Xapian/DatabaseCreateError.pm Xapian/DatabaseError.pm Xapian/DatabaseLockError.pm Xapian/DatabaseModifiedError.pm Xapian/DatabaseNotFoundError.pm Xapian/DatabaseOpeningError.pm Xapian/DatabaseVersionError.pm Xapian/DocNotFoundError.pm Xapian/Error.pm Xapian/FeatureUnavailableError.pm Xapian/InternalError.pm Xapian/InvalidArgumentError.pm Xapian/InvalidOperationError.pm Xapian/LogicError.pm Xapian/NetworkError.pm Xapian/NetworkTimeoutError.pm Xapian/QueryParserError.pm Xapian/RangeError.pm Xapian/RuntimeError.pm Xapian/SerialisationError.pm Xapian/UnimplementedError.pm Xapian/WildcardError.pm XS/AssertionError.xs XS/DatabaseClosedError.xs XS/DatabaseCorruptError.xs XS/DatabaseCreateError.xs XS/DatabaseError.xs XS/DatabaseLockError.xs XS/DatabaseModifiedError.xs XS/DatabaseNotFoundError.xs XS/DatabaseOpeningError.xs XS/DatabaseVersionError.xs XS/DocNotFoundError.xs XS/Error.xs XS/FeatureUnavailableError.xs XS/InternalError.xs XS/InvalidArgumentError.xs XS/InvalidOperationError.xs XS/LogicError.xs XS/NetworkError.xs XS/NetworkTimeoutError.xs XS/QueryParserError.xs XS/RangeError.xs XS/RuntimeError.xs XS/SerialisationError.xs XS/UnimplementedError.xs XS/WildcardError.xs t/01use.t t/02pod.t t/03podcoverage.t t/04functions.t t/10query.t t/collapse.t t/create.t t/databasemodified.t t/document.t t/exception.t t/facets.t t/index.t t/parser.t t/search.t t/sorter.t t/symbol-test.t t/symbol-test/Makefile.PL t/symbol-test/SymbolTest.pm t/symbol-test/SymbolTest.xs t/symbol-test/typemap t/termgenerator.t t/thread.t t/tied.t t/valuerange.t t/writabledatabase.t examples/full-indexer.pl examples/full-searcher.pl examples/simpleexpand.pl examples/simpleindex.pl examples/simplematchdecider.pl examples/simplesearch.pl META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Search-Xapian-1.2.25.5/META.json0000644000175000017500000000235414207007026014532 0ustar ollyolly{ "abstract" : "Perl XS frontend to the Xapian C++ search library.", "author" : [ "Alex Bowley " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Search-Xapian", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "Devel::Leak" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "perl" : "5.006000" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://trac.xapian.org/" }, "homepage" : "https://xapian.org/", "repository" : { "type" : "git", "web" : "https://git.xapian.org/?p=xapian;a=tree;f=search-xapian;hb=refs/heads/svn/1.2" } }, "version" : "v1.2.25.5", "x_serialization_backend" : "JSON::PP version 4.06" } Search-Xapian-1.2.25.5/XS/0000755000175000017500000000000014207007026013437 5ustar ollyollySearch-Xapian-1.2.25.5/XS/MSet.xs0000644000175000017500000000361513320553070014670 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::MSet PROTOTYPES: ENABLE MSet * new1() CODE: RETVAL = new MSet(); OUTPUT: RETVAL MSet * new2(other) MSet * other CODE: RETVAL = new MSet(*other); OUTPUT: RETVAL void MSet::fetch1(begin, end) MSetIterator * begin MSetIterator * end CODE: THIS->fetch(*begin, *end); void MSet::fetch2(item) MSetIterator * item CODE: THIS->fetch(*item); void MSet::fetch3() CODE: THIS->fetch(); int MSet::convert_to_percent1(wt) double wt CODE: RETVAL = THIS->convert_to_percent(wt); OUTPUT: RETVAL int MSet::convert_to_percent2(it) MSetIterator * it CODE: RETVAL = THIS->convert_to_percent(*it); OUTPUT: RETVAL doccount MSet::get_termfreq(tname) string tname CODE: RETVAL = THIS->get_termfreq(tname); OUTPUT: RETVAL double MSet::get_termweight(tname) string tname CODE: RETVAL = THIS->get_termweight(tname); OUTPUT: RETVAL doccount MSet::get_firstitem() doccount MSet::get_matches_lower_bound() doccount MSet::get_matches_estimated() doccount MSet::get_matches_upper_bound() double MSet::get_max_possible() double MSet::get_max_attained() doccount MSet::size() ALIAS: Search::Xapian::MSet::FETCHSIZE = 1 bool MSet::empty() void MSet::swap(other) MSet * other CODE: THIS->swap(*other); MSetIterator * MSet::begin() CODE: RETVAL = new MSetIterator(THIS->begin()); OUTPUT: RETVAL MSetIterator * MSet::end() CODE: RETVAL = new MSetIterator(THIS->end()); OUTPUT: RETVAL MSetIterator * MSet::back() CODE: RETVAL = new MSetIterator(THIS->back()); OUTPUT: RETVAL MSetIterator * MSet::FETCH(doccount i) # get_msetiterator() alias for backward compatibility. ALIAS: Search::Xapian::MSet::get_msetiterator = 1 CODE: RETVAL = new MSetIterator((*THIS)[i]); OUTPUT: RETVAL string MSet::get_description() void MSet::DESTROY() Search-Xapian-1.2.25.5/XS/TermIterator.xs0000644000175000017500000000225413320553070016437 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::TermIterator PROTOTYPES: ENABLE TermIterator * new1() CODE: RETVAL = new TermIterator(); OUTPUT: RETVAL TermIterator * new2(other) TermIterator * other CODE: RETVAL = new TermIterator(*other); OUTPUT: RETVAL void TermIterator::DESTROY() TermIterator * TermIterator::inc() CODE: RETVAL = new TermIterator(++(*THIS)); OUTPUT: RETVAL bool TermIterator::equal(that) TermIterator * that CODE: RETVAL = ((*THIS) == (*that)); OUTPUT: RETVAL bool TermIterator::nequal(that) TermIterator * that CODE: RETVAL = ((*THIS) != (*that)); OUTPUT: RETVAL string TermIterator::get_termname() CODE: RETVAL = THIS->operator*(); OUTPUT: RETVAL void TermIterator::skip_to(string tname) termcount TermIterator::get_wdf() doccount TermIterator::get_termfreq() PositionIterator * TermIterator::positionlist_begin() CODE: RETVAL = new PositionIterator(THIS->positionlist_begin()); OUTPUT: RETVAL PositionIterator * TermIterator::positionlist_end() CODE: RETVAL = new PositionIterator(THIS->positionlist_end()); OUTPUT: RETVAL string TermIterator::get_description() Search-Xapian-1.2.25.5/XS/DatabaseModifiedError.xs0000644000175000017500000000047414207005157020202 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseModifiedError PROTOTYPES: ENABLE string DatabaseModifiedError::get_type() string DatabaseModifiedError::get_msg() string DatabaseModifiedError::get_context() const char * DatabaseModifiedError::get_error_string() void DatabaseModifiedError::DESTROY() Search-Xapian-1.2.25.5/XS/NetworkTimeoutError.xs0000644000175000017500000000046014207005157020030 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::NetworkTimeoutError PROTOTYPES: ENABLE string NetworkTimeoutError::get_type() string NetworkTimeoutError::get_msg() string NetworkTimeoutError::get_context() const char * NetworkTimeoutError::get_error_string() void NetworkTimeoutError::DESTROY() Search-Xapian-1.2.25.5/XS/PositionIterator.xs0000644000175000017500000000151013320553070017326 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::PositionIterator PROTOTYPES: ENABLE PositionIterator * new1() CODE: RETVAL = new PositionIterator(); OUTPUT: RETVAL PositionIterator * new2(other) PositionIterator * other CODE: RETVAL = new PositionIterator(*other); OUTPUT: RETVAL void PositionIterator::DESTROY() void PositionIterator::inc() CODE: ++(*THIS); bool PositionIterator::equal1(that) PositionIterator * that CODE: RETVAL = ((*THIS) == (*that)); OUTPUT: RETVAL bool PositionIterator::nequal1(that) PositionIterator * that CODE: RETVAL = ((*THIS) != (*that)); OUTPUT: RETVAL termpos PositionIterator::get_termpos() CODE: RETVAL = THIS->operator*(); OUTPUT: RETVAL void PositionIterator::skip_to(termpos pos) string PositionIterator::get_description() Search-Xapian-1.2.25.5/XS/StringValueRangeProcessor.xs0000644000175000017500000000137113320553070021135 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::StringValueRangeProcessor PROTOTYPES: ENABLE StringValueRangeProcessor * StringValueRangeProcessor::new(valno, str = NO_INIT, prefix = true) valueno valno string str bool prefix CODE: switch (items) { /* items includes the hidden this pointer */ case 2: RETVAL = new StringValueRangeProcessor(valno); break; case 3: case 4: RETVAL = new StringValueRangeProcessor(valno, str, prefix); break; default: croak("Bad parameter count for new"); } OUTPUT: RETVAL valueno StringValueRangeProcessor::process_value_range(begin, end) string & begin; string & end; CODE: RETVAL = (*THIS)(begin, end); OUTPUT: RETVAL void StringValueRangeProcessor::DESTROY() Search-Xapian-1.2.25.5/XS/ESetIterator.xs0000644000175000017500000000144313320553070016367 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::ESetIterator PROTOTYPES: ENABLE ESetIterator * new1() CODE: RETVAL = new ESetIterator(); OUTPUT: RETVAL ESetIterator * new2(other) ESetIterator * other CODE: RETVAL = new ESetIterator(* other); OUTPUT: RETVAL void ESetIterator::inc() CODE: ++(*THIS); void ESetIterator::dec() CODE: --(*THIS); bool ESetIterator::equal(ESetIterator * that) CODE: RETVAL = ((*THIS) == (*that)); OUTPUT: RETVAL bool ESetIterator::nequal(ESetIterator * that) CODE: RETVAL = ((*THIS) != (*that)); OUTPUT: RETVAL string ESetIterator::get_termname() CODE: RETVAL = THIS->operator*(); OUTPUT: RETVAL double ESetIterator::get_weight() string ESetIterator::get_description() void ESetIterator::DESTROY() Search-Xapian-1.2.25.5/XS/MSetIterator.xs0000644000175000017500000000202713320553070016376 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::MSetIterator PROTOTYPES: ENABLE MSetIterator * new1() CODE: RETVAL = new MSetIterator(); OUTPUT: RETVAL MSetIterator * new2(other) MSetIterator * other CODE: RETVAL = new MSetIterator(* other); OUTPUT: RETVAL void MSetIterator::inc() CODE: ++(*THIS); void MSetIterator::dec() CODE: --(*THIS); bool MSetIterator::equal(that) MSetIterator * that CODE: RETVAL = ((*THIS) == (*that)); OUTPUT: RETVAL bool MSetIterator::nequal(that) MSetIterator * that CODE: RETVAL = ((*THIS) != (*that)); OUTPUT: RETVAL docid MSetIterator::get_docid() CODE: RETVAL = THIS->operator*(); OUTPUT: RETVAL Document * MSetIterator::get_document() CODE: RETVAL = new Document(THIS->get_document()); OUTPUT: RETVAL doccount MSetIterator::get_rank() double MSetIterator::get_weight() doccount MSetIterator::get_collapse_count() int MSetIterator::get_percent() string MSetIterator::get_description() void MSetIterator::DESTROY() Search-Xapian-1.2.25.5/XS/Weight.xs0000644000175000017500000000012013320553070015233 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::Weight PROTOTYPES: ENABLE Search-Xapian-1.2.25.5/XS/Stopper.xs0000644000175000017500000000031113320553070015442 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::Stopper PROTOTYPES: ENABLE bool Stopper::stop_word(term) string term; CODE: RETVAL = (*THIS)(term); OUTPUT: RETVAL void Stopper::DESTROY() Search-Xapian-1.2.25.5/XS/QueryParserError.xs0000644000175000017500000000043614207005157017315 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::QueryParserError PROTOTYPES: ENABLE string QueryParserError::get_type() string QueryParserError::get_msg() string QueryParserError::get_context() const char * QueryParserError::get_error_string() void QueryParserError::DESTROY() Search-Xapian-1.2.25.5/XS/DatabaseNotFoundError.xs0000644000175000017500000000047413756405004020221 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseNotFoundError PROTOTYPES: ENABLE string DatabaseNotFoundError::get_type() string DatabaseNotFoundError::get_msg() string DatabaseNotFoundError::get_context() const char * DatabaseNotFoundError::get_error_string() void DatabaseNotFoundError::DESTROY() Search-Xapian-1.2.25.5/XS/InvalidArgumentError.xs0000644000175000017500000000046614207005157020127 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::InvalidArgumentError PROTOTYPES: ENABLE string InvalidArgumentError::get_type() string InvalidArgumentError::get_msg() string InvalidArgumentError::get_context() const char * InvalidArgumentError::get_error_string() void InvalidArgumentError::DESTROY() Search-Xapian-1.2.25.5/XS/InternalError.xs0000644000175000017500000000041414207005157016603 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::InternalError PROTOTYPES: ENABLE string InternalError::get_type() string InternalError::get_msg() string InternalError::get_context() const char * InternalError::get_error_string() void InternalError::DESTROY() Search-Xapian-1.2.25.5/XS/ValueCountMatchSpy.xs0000644000175000017500000000246213320553070017555 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::ValueCountMatchSpy PROTOTYPES: ENABLE ValueCountMatchSpy * new1() CODE: RETVAL = new ValueCountMatchSpy(); OUTPUT: RETVAL ValueCountMatchSpy * new2(slot) valueno slot CODE: RETVAL = new ValueCountMatchSpy(slot); OUTPUT: RETVAL void ValueCountMatchSpy::DESTROY() size_t ValueCountMatchSpy::get_total() CODE: try { RETVAL = THIS->get_total(); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * ValueCountMatchSpy::values_begin() CODE: try { RETVAL = new TermIterator(THIS->values_begin()); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * ValueCountMatchSpy::values_end() CODE: try { RETVAL = new TermIterator(THIS->values_end()); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * ValueCountMatchSpy::top_values_begin(maxvalues) size_t maxvalues CODE: try { RETVAL = new TermIterator(THIS->top_values_begin(maxvalues)); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * ValueCountMatchSpy::top_values_end(maxvalues) size_t maxvalues CODE: try { RETVAL = new TermIterator(THIS->top_values_end(maxvalues)); } catch (...) { handle_exception(); } OUTPUT: RETVAL Search-Xapian-1.2.25.5/XS/ValueIterator.xs0000644000175000017500000000142213320553070016600 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::ValueIterator PROTOTYPES: ENABLE ValueIterator * new1() CODE: RETVAL = new ValueIterator(); OUTPUT: RETVAL ValueIterator * new2(other) ValueIterator * other CODE: RETVAL = new ValueIterator(*other); OUTPUT: RETVAL void ValueIterator::DESTROY() void ValueIterator::inc() CODE: ++(*THIS); bool ValueIterator::equal(that) ValueIterator * that CODE: RETVAL = ((*THIS) == (*that)); OUTPUT: RETVAL bool ValueIterator::nequal(that) ValueIterator * that CODE: RETVAL = ((*THIS) != (*that)); OUTPUT: RETVAL string ValueIterator::get_value() CODE: RETVAL = THIS->operator*(); OUTPUT: RETVAL valueno ValueIterator::get_valueno() string ValueIterator::get_description() Search-Xapian-1.2.25.5/XS/PostingIterator.xs0000644000175000017500000000244113320553070017151 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::PostingIterator PROTOTYPES: ENABLE PostingIterator * new1() CODE: RETVAL = new PostingIterator(); OUTPUT: RETVAL PostingIterator * new2(other) PostingIterator * other CODE: RETVAL = new PostingIterator(*other); OUTPUT: RETVAL void PostingIterator::DESTROY() void PostingIterator::inc() CODE: ++(*THIS); bool PostingIterator::equal1(that) PostingIterator * that CODE: RETVAL = ((*THIS) == (*that)); OUTPUT: RETVAL bool PostingIterator::nequal1(that) PostingIterator * that CODE: RETVAL = ((*THIS) != (*that)); OUTPUT: RETVAL docid PostingIterator::get_docid() CODE: RETVAL = THIS->operator*(); OUTPUT: RETVAL doclength PostingIterator::get_doclength() CODE: RETVAL = THIS->get_doclength(); OUTPUT: RETVAL termcount PostingIterator::get_wdf() CODE: RETVAL = THIS->get_wdf(); OUTPUT: RETVAL string PostingIterator::get_description() PositionIterator * PostingIterator::positionlist_begin() CODE: RETVAL = new PositionIterator(THIS->positionlist_begin()); OUTPUT: RETVAL PositionIterator * PostingIterator::positionlist_end() CODE: RETVAL = new PositionIterator(THIS->positionlist_end()); OUTPUT: RETVAL void PostingIterator::skip_to(docid pos) Search-Xapian-1.2.25.5/XS/TradWeight.xs0000644000175000017500000000043313320553070016055 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::TradWeight PROTOTYPES: ENABLE TradWeight * new1() CODE: RETVAL = new TradWeight(); OUTPUT: RETVAL TradWeight * new2(k) double k CODE: RETVAL = new TradWeight(k); OUTPUT: RETVAL void TradWeight::DESTROY() Search-Xapian-1.2.25.5/XS/RangeError.xs0000644000175000017500000000037214207005157016066 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::RangeError PROTOTYPES: ENABLE string RangeError::get_type() string RangeError::get_msg() string RangeError::get_context() const char * RangeError::get_error_string() void RangeError::DESTROY() Search-Xapian-1.2.25.5/XS/Query.xs0000644000175000017500000000362113320553070015122 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::Query PROTOTYPES: ENABLE Query * new0() CODE: RETVAL = new Query(); OUTPUT: RETVAL Query * new1(term) string term CODE: RETVAL = new Query(term); OUTPUT: RETVAL Query * new1weight(term, wqf, pos) string term termcount wqf termpos pos CODE: RETVAL = new Query(term, wqf, pos); OUTPUT: RETVAL Query * new3scale(int op, Query * query, double factor) CODE: RETVAL = new Query( (Query::op) op, *query, factor ); OUTPUT: RETVAL Query * new3range(op, valno, limit) int op valueno valno string limit CODE: RETVAL = new Query( (Query::op) op, valno, limit ); OUTPUT: RETVAL Query * new4range(op, valno, start, end) int op valueno valno string start string end CODE: RETVAL = new Query( (Query::op) op, valno, start, end ); OUTPUT: RETVAL Query * newN(int op_, ...) CODE: Query::op op = (Query::op)op_; try { vector queries; queries.reserve(items - 1); for( int i = 1; i < items; i++ ) { SV *sv = ST (i); if (sv_isa(sv, "Search::Xapian::Query")) { Query *query = (Query*) SvIV((SV*) SvRV(sv)); queries.push_back(*query); } else if ( SvOK(sv) ) { STRLEN len; const char * ptr = SvPV(sv, len); queries.push_back(Query(string(ptr, len))); } else { croak( "USAGE: Search::Xapian::Query->new(OP, @TERMS_OR_QUERY_OBJECTS)" ); } } RETVAL = new Query(op, queries.begin(), queries.end()); } catch (...) { handle_exception(); } OUTPUT: RETVAL termcount Query::get_length() TermIterator * Query::get_terms_begin() CODE: RETVAL = new TermIterator(THIS->get_terms_begin()); OUTPUT: RETVAL TermIterator * Query::get_terms_end() CODE: RETVAL = new TermIterator(THIS->get_terms_end()); OUTPUT: RETVAL bool Query::empty() string Query::get_description() void Query::DESTROY() Search-Xapian-1.2.25.5/XS/DatabaseCreateError.xs0000644000175000017500000000046014207005157017660 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseCreateError PROTOTYPES: ENABLE string DatabaseCreateError::get_type() string DatabaseCreateError::get_msg() string DatabaseCreateError::get_context() const char * DatabaseCreateError::get_error_string() void DatabaseCreateError::DESTROY() Search-Xapian-1.2.25.5/XS/Enquire.xs0000644000175000017500000001547713320553434015445 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::Enquire PROTOTYPES: ENABLE Enquire * Enquire::new(databases) Database * databases CODE: try { RETVAL = XAPIAN_PERL_NEW(Enquire, (*databases)); } catch (...) { handle_exception(); } OUTPUT: RETVAL void Enquire::set_query1(query) Query * query CODE: try { THIS->set_query(*query); } catch (...) { handle_exception(); } void Enquire::set_query2(query, len) Query * query termcount len CODE: try { THIS->set_query(*query, len); } catch (...) { handle_exception(); } Query * Enquire::get_query() CODE: try { RETVAL = new Query(THIS->get_query()); } catch (...) { handle_exception(); } OUTPUT: RETVAL void Enquire::set_collapse_key(collapse_key, collapse_max = 1) valueno collapse_key doccount collapse_max CODE: try { THIS->set_collapse_key(collapse_key, collapse_max); } catch (...) { handle_exception(); } void Enquire::set_docid_order(order) int order CODE: try { THIS->set_docid_order(static_cast(order)); } catch (...) { handle_exception(); } void Enquire::set_cutoff(percent_cutoff, weight_cutoff = NO_INIT) int percent_cutoff double weight_cutoff CODE: try { if (items == 3) { /* items includes the hidden this pointer */ THIS->set_cutoff(percent_cutoff, weight_cutoff); } else { THIS->set_cutoff(percent_cutoff); } } catch (...) { handle_exception(); } void Enquire::set_sort_by_relevance() CODE: // Clear reference to any currently set sorter object. XAPIAN_PERL_REF(Enquire, THIS, sorter, NULL); THIS->set_sort_by_relevance(); void Enquire::set_sort_by_value(sort_key, ascending = true) valueno sort_key bool ascending CODE: // Clear reference to any currently set sorter object. XAPIAN_PERL_REF(Enquire, THIS, sorter, NULL); try { THIS->set_sort_by_value(sort_key, ascending); } catch (...) { handle_exception(); } void Enquire::set_sort_by_value_then_relevance(sort_key, ascending = true) valueno sort_key bool ascending CODE: // Clear reference to any currently set sorter object. XAPIAN_PERL_REF(Enquire, THIS, sorter, NULL); try { THIS->set_sort_by_value_then_relevance(sort_key, ascending); } catch (...) { handle_exception(); } void Enquire::set_sort_by_relevance_then_value(sort_key, ascending = true) valueno sort_key bool ascending CODE: // Clear reference to any currently set sorter object. XAPIAN_PERL_REF(Enquire, THIS, sorter, NULL); try { THIS->set_sort_by_relevance_then_value(sort_key, ascending); } catch (...) { handle_exception(); } void Enquire::set_sort_by_key(sorter, ascending = true) MultiValueKeyMaker * sorter bool ascending CODE: // Keep a reference to the currently set object. XAPIAN_PERL_REF(Enquire, THIS, sorter, ST(1)); try { THIS->set_sort_by_key(sorter, ascending); } catch (...) { handle_exception(); } void Enquire::set_sort_by_key_then_relevance(sorter, ascending = true) MultiValueKeyMaker * sorter bool ascending CODE: // Keep a reference to the currently set object. XAPIAN_PERL_REF(Enquire, THIS, sorter, ST(1)); try { THIS->set_sort_by_key_then_relevance(sorter, ascending); } catch (...) { handle_exception(); } void Enquire::set_sort_by_relevance_then_key(sorter, ascending = true) MultiValueKeyMaker * sorter bool ascending CODE: // Keep a reference to the currently set object. XAPIAN_PERL_REF(Enquire, THIS, sorter, ST(1)); try { THIS->set_sort_by_relevance_then_key(sorter, ascending); } catch (...) { handle_exception(); } MSet * Enquire::get_mset1(first, maxitems, checkatleast = NO_INIT, rset = NO_INIT, func = NO_INIT) doccount first doccount maxitems doccount checkatleast RSet * rset SV * func CODE: try { MSet mset; switch (items) { /* items includes the hidden this pointer */ case 3: mset = THIS->get_mset(first, maxitems); break; case 4: mset = THIS->get_mset(first, maxitems, checkatleast); break; case 5: mset = THIS->get_mset(first, maxitems, checkatleast, rset); break; case 6: { perlMatchDecider d(func); mset = THIS->get_mset(first, maxitems, checkatleast, rset, &d); break; } default: croak("Bad parameter count for get_mset1"); } RETVAL = new MSet(mset); } catch (...) { handle_exception(); } OUTPUT: RETVAL MSet * Enquire::get_mset2(first, maxitems, func) doccount first doccount maxitems SV * func CODE: try { perlMatchDecider d(func); RETVAL = new MSet(THIS->get_mset(first, maxitems, 0, NULL, &d)); } catch (...) { handle_exception(); } OUTPUT: RETVAL ESet * Enquire::get_eset(maxitems, rset, func = NO_INIT) doccount maxitems RSet * rset SV * func CODE: try { ESet eset; switch (items) { /* items includes the hidden this pointer */ case 3: eset = THIS->get_eset(maxitems, *rset); break; case 4: { perlExpandDecider d(func); eset = THIS->get_eset(maxitems, *rset, &d); break; } default: croak("Bad parameter count for get_eset"); } RETVAL = new ESet(eset); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Enquire::get_matching_terms_begin1(docid did) CODE: try { RETVAL = new TermIterator(THIS->get_matching_terms_begin(did)); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Enquire::get_matching_terms_begin2(it) MSetIterator * it CODE: try { RETVAL = new TermIterator(THIS->get_matching_terms_begin(* it)); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Enquire::get_matching_terms_end1(docid did) CODE: try { RETVAL = new TermIterator(THIS->get_matching_terms_end(did)); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Enquire::get_matching_terms_end2(it) MSetIterator * it CODE: try { RETVAL = new TermIterator(THIS->get_matching_terms_end(* it)); } catch (...) { handle_exception(); } OUTPUT: RETVAL void Enquire::set_weighting_scheme(weight_) Weight * weight_ CODE: try { THIS->set_weighting_scheme(*weight_); } catch (...) { handle_exception(); } string Enquire::get_description() void Enquire::add_matchspy(MatchSpy * spy) CODE: try { XAPIAN_PERL_REF(Enquire, THIS, matchspy, ST(1)); THIS->add_matchspy(spy); } catch (...) { handle_exception(); } void Enquire::clear_matchspies() CODE: try { XAPIAN_PERL_REF(Enquire, THIS, clear_matchspies, NULL); THIS->clear_matchspies(); } catch (...) { handle_exception(); } void Enquire::DESTROY() CODE: XAPIAN_PERL_DESTROY(Enquire, THIS); Search-Xapian-1.2.25.5/XS/UnimplementedError.xs0000644000175000017500000000045214207005157017637 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::UnimplementedError PROTOTYPES: ENABLE string UnimplementedError::get_type() string UnimplementedError::get_msg() string UnimplementedError::get_context() const char * UnimplementedError::get_error_string() void UnimplementedError::DESTROY() Search-Xapian-1.2.25.5/XS/AssertionError.xs0000644000175000017500000000042214207005157016775 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::AssertionError PROTOTYPES: ENABLE string AssertionError::get_type() string AssertionError::get_msg() string AssertionError::get_context() const char * AssertionError::get_error_string() void AssertionError::DESTROY() Search-Xapian-1.2.25.5/XS/DocNotFoundError.xs0000644000175000017500000000043614207005157017215 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DocNotFoundError PROTOTYPES: ENABLE string DocNotFoundError::get_type() string DocNotFoundError::get_msg() string DocNotFoundError::get_context() const char * DocNotFoundError::get_error_string() void DocNotFoundError::DESTROY() Search-Xapian-1.2.25.5/XS/TermGenerator.xs0000644000175000017500000000275613320553070016603 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::TermGenerator PROTOTYPES: ENABLE TermGenerator * new0() CODE: RETVAL = XAPIAN_PERL_NEW(TermGenerator, ()); OUTPUT: RETVAL void TermGenerator::set_stemmer(stemmer) Stem * stemmer CODE: THIS->set_stemmer(*stemmer); void TermGenerator::set_stopper(stopper) Stopper * stopper CODE: // Keep a reference to the currently set object. XAPIAN_PERL_REF(TermGenerator, THIS, stopper, ST(1)); THIS->set_stopper(stopper); void TermGenerator::set_database(db) WritableDatabase * db CODE: THIS->set_database(*db); void TermGenerator::set_document(Document * doc) CODE: THIS->set_document(*doc); Document * TermGenerator::get_document() CODE: RETVAL = new Document(THIS->get_document()); OUTPUT: RETVAL void TermGenerator::index_text(text, weight = 1, prefix = NO_INIT) string text termcount weight string prefix int TermGenerator::set_flags(int toggle, int mask = 0) CODE: RETVAL = THIS->set_flags(TermGenerator::flags(toggle), TermGenerator::flags(mask)); OUTPUT: RETVAL void TermGenerator::index_text_without_positions(text, weight = 1, prefix = NO_INIT) string text termcount weight string prefix void TermGenerator::increase_termpos(termcount delta = 100) termcount TermGenerator::get_termpos() void TermGenerator::set_termpos(termcount termpos) string TermGenerator::get_description() void TermGenerator::DESTROY() CODE: XAPIAN_PERL_DESTROY(TermGenerator, THIS); Search-Xapian-1.2.25.5/XS/MultiValueSorter.xs0000644000175000017500000000067313320553070017307 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::MultiValueSorter PROTOTYPES: ENABLE MultiValueKeyMaker * new0() CODE: RETVAL = new MultiValueKeyMaker(); OUTPUT: RETVAL void MultiValueKeyMaker::add(valueno valno, bool forward = NO_INIT) CODE: if (items == 3) { /* items includes the hidden this pointer */ THIS->add_value(valno, !forward); } else { THIS->add_value(valno); } void MultiValueKeyMaker::DESTROY() Search-Xapian-1.2.25.5/XS/Document.xs0000644000175000017500000000654313320553070015601 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::Document PROTOTYPES: ENABLE Document * new1() CODE: RETVAL = new Document(); OUTPUT: RETVAL Document * new2(other) Document * other CODE: RETVAL = new Document(*other); OUTPUT: RETVAL string Document::get_value(valueno valno) CODE: try { RETVAL = THIS->get_value(valno); } catch (...) { handle_exception(); } OUTPUT: RETVAL void Document::add_value(valno, value) valueno valno string value CODE: try { THIS->add_value(valno, value); } catch (...) { handle_exception(); } void Document::remove_value(valueno valno) CODE: try { THIS->remove_value(valno); } catch (...) { handle_exception(); } void Document::clear_values() string Document::get_data() CODE: try { RETVAL = THIS->get_data(); } catch (...) { handle_exception(); } OUTPUT: RETVAL void Document::set_data(data) string data CODE: THIS->set_data(data); void Document::add_posting(tname, tpos, wdfinc = NO_INIT) string tname termpos tpos termcount wdfinc CODE: try { if (items == 4) { /* items includes the hidden this pointer */ THIS->add_posting(tname, tpos, wdfinc); } else { THIS->add_posting(tname, tpos); } } catch (...) { handle_exception(); } void Document::add_term(tname, wdfinc = NO_INIT) string tname termcount wdfinc CODE: try { if (items == 3) { /* items includes the hidden this pointer */ THIS->add_term(tname, wdfinc); } else { THIS->add_term(tname); } } catch (...) { handle_exception(); } void Document::add_boolean_term(tname) string tname CODE: try { THIS->add_boolean_term(tname); } catch (...) { handle_exception(); } void Document::remove_posting(tname, tpos, wdfdec = NO_INIT) string tname termpos tpos termcount wdfdec CODE: try { if (items == 4) { /* items includes the hidden this pointer */ THIS->remove_posting(tname, tpos, wdfdec); } else { THIS->remove_posting(tname, tpos); } } catch (...) { handle_exception(); } void Document::remove_term(tname) string tname CODE: try { THIS->remove_term(tname); } catch (...) { handle_exception(); } void Document::clear_terms() termcount Document::termlist_count() CODE: try { RETVAL = THIS->termlist_count(); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Document::termlist_begin() CODE: try { RETVAL = new TermIterator(THIS->termlist_begin()); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Document::termlist_end() CODE: RETVAL = new TermIterator(THIS->termlist_end()); OUTPUT: RETVAL termcount Document::values_count() CODE: try { RETVAL = THIS->values_count(); } catch (...) { handle_exception(); } OUTPUT: RETVAL ValueIterator * Document::values_begin() CODE: try { RETVAL = new ValueIterator(THIS->values_begin()); } catch (...) { handle_exception(); } OUTPUT: RETVAL ValueIterator * Document::values_end() CODE: RETVAL = new ValueIterator(THIS->values_end()); OUTPUT: RETVAL docid Document::get_docid() CODE: try { RETVAL = THIS->get_docid(); } catch (...) { handle_exception(); } OUTPUT: RETVAL string Document::get_description() void Document::DESTROY() Search-Xapian-1.2.25.5/XS/LogicError.xs0000644000175000017500000000060414207005157016065 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::LogicError PROTOTYPES: ENABLE string LogicError::get_type() string LogicError::get_msg() string LogicError::get_context() const char * LogicError::get_error_string() void LogicError::DESTROY() INCLUDE: XS/AssertionError.xs INCLUDE: XS/InvalidArgumentError.xs INCLUDE: XS/InvalidOperationError.xs INCLUDE: XS/UnimplementedError.xs Search-Xapian-1.2.25.5/XS/DatabaseOpeningError.xs0000644000175000017500000000053314207005157020055 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseOpeningError PROTOTYPES: ENABLE string DatabaseOpeningError::get_type() string DatabaseOpeningError::get_msg() string DatabaseOpeningError::get_context() const char * DatabaseOpeningError::get_error_string() void DatabaseOpeningError::DESTROY() INCLUDE: XS/DatabaseVersionError.xs Search-Xapian-1.2.25.5/XS/RSet.xs0000644000175000017500000000160113320553070014666 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::RSet PROTOTYPES: ENABLE RSet * new1() CODE: RETVAL = new RSet(); OUTPUT: RETVAL RSet * new2(other) RSet * other CODE: RETVAL = new RSet(*other); OUTPUT: RETVAL doccount RSet::size() bool RSet::empty() void RSet::add_document1(it) MSetIterator * it CODE: THIS->add_document(*it); void RSet::add_document2(did) docid did CODE: THIS->add_document(did); void RSet::remove_document1(it) MSetIterator * it CODE: THIS->remove_document(*it); void RSet::remove_document2(did) docid did CODE: THIS->remove_document(did); bool RSet::contains1(it) MSetIterator * it CODE: RETVAL = THIS->contains(*it); OUTPUT: RETVAL bool RSet::contains2(did) docid did CODE: RETVAL = THIS->contains(did); OUTPUT: RETVAL string RSet::get_description() void RSet::DESTROY() Search-Xapian-1.2.25.5/XS/Stem.xs0000644000175000017500000000060213320553070014721 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::Stem PROTOTYPES: ENABLE Stem * Stem::new(language) string language CODE: try { RETVAL = new Stem(language); } catch (...) { handle_exception(); } OUTPUT: RETVAL string Stem::stem_word(string word) CODE: RETVAL = (*THIS)(word); OUTPUT: RETVAL string Stem::get_description() void Stem::DESTROY() Search-Xapian-1.2.25.5/XS/NumberValueRangeProcessor.xs0000644000175000017500000000112113320553070021110 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::NumberValueRangeProcessor PROTOTYPES: ENABLE NumberValueRangeProcessor * NumberValueRangeProcessor::new(valueno valno, string str = NO_INIT, bool prefix = true) CODE: if (items == 2) { RETVAL = new NumberValueRangeProcessor(valno); } else { RETVAL = new NumberValueRangeProcessor(valno, str, prefix); } OUTPUT: RETVAL valueno NumberValueRangeProcessor::process_value_range(begin, end) string & begin; string & end; CODE: RETVAL = (*THIS)(begin, end); OUTPUT: RETVAL void NumberValueRangeProcessor::DESTROY() Search-Xapian-1.2.25.5/XS/DateValueRangeProcessor.xs0000644000175000017500000000077613320553070020554 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DateValueRangeProcessor PROTOTYPES: ENABLE DateValueRangeProcessor * DateValueRangeProcessor::new(valueno valno, bool prefer_mdy = false, int epoch_year = 1970) CODE: RETVAL = new DateValueRangeProcessor(valno, prefer_mdy, epoch_year); OUTPUT: RETVAL valueno DateValueRangeProcessor::process_value_range(begin, end) string & begin; string & end; CODE: RETVAL = (*THIS)(begin, end); OUTPUT: RETVAL void DateValueRangeProcessor::DESTROY() Search-Xapian-1.2.25.5/XS/SimpleStopper.xs0000644000175000017500000000053513320553070016624 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::SimpleStopper PROTOTYPES: ENABLE SimpleStopper * new0() CODE: RETVAL = new SimpleStopper(); OUTPUT: RETVAL bool SimpleStopper::stop_word(term) string term; CODE: RETVAL = (*THIS)(term); OUTPUT: RETVAL void SimpleStopper::add(string term) void SimpleStopper::DESTROY() Search-Xapian-1.2.25.5/XS/DatabaseClosedError.xs0000644000175000017500000000046013756405004017671 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseClosedError PROTOTYPES: ENABLE string DatabaseClosedError::get_type() string DatabaseClosedError::get_msg() string DatabaseClosedError::get_context() const char * DatabaseClosedError::get_error_string() void DatabaseClosedError::DESTROY() Search-Xapian-1.2.25.5/XS/BoolWeight.xs0000644000175000017500000000036513320553070016062 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::BoolWeight PROTOTYPES: ENABLE BoolWeight * new1() CODE: try { RETVAL = new BoolWeight(); } catch (...) { handle_exception(); } OUTPUT: RETVAL void BoolWeight::DESTROY() Search-Xapian-1.2.25.5/XS/ESet.xs0000644000175000017500000000147413320553070014661 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::ESet PROTOTYPES: ENABLE ESet * new1() CODE: RETVAL = new ESet(); OUTPUT: RETVAL ESet * new2(other) ESet * other CODE: RETVAL = new ESet(*other); OUTPUT: RETVAL termcount ESet::get_ebound() termcount ESet::size() ALIAS: Search::Xapian::ESet::FETCHSIZE = 1 bool ESet::empty() ESetIterator * ESet::begin() CODE: RETVAL = new ESetIterator(THIS->begin()); OUTPUT: RETVAL ESetIterator * ESet::end() CODE: RETVAL = new ESetIterator(THIS->end()); OUTPUT: RETVAL ESetIterator * ESet::back() CODE: RETVAL = new ESetIterator(THIS->back()); OUTPUT: RETVAL ESetIterator * ESet::FETCH(doccount i) CODE: RETVAL = new ESetIterator((*THIS)[i]); OUTPUT: RETVAL string ESet::get_description() void ESet::DESTROY() Search-Xapian-1.2.25.5/XS/WritableDatabase.xs0000644000175000017500000000675613350560532017233 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::WritableDatabase PROTOTYPES: ENABLE WritableDatabase * new1(file, opts) string file int opts CODE: try { RETVAL = new WritableDatabase(file, opts); } catch (...) { handle_exception(); } OUTPUT: RETVAL WritableDatabase * new2(database) WritableDatabase * database CODE: RETVAL = new WritableDatabase(*database); OUTPUT: RETVAL WritableDatabase * new3() CODE: try { #if XAPIAN_AT_LEAST(1,5,0) RETVAL = new WritableDatabase(std::string(), Xapian::DB_BACKEND_INMEMORY); #else RETVAL = new WritableDatabase(InMemory::open()); #endif } catch (...) { handle_exception(); } OUTPUT: RETVAL void WritableDatabase::flush() CODE: try { THIS->commit(); } catch (...) { handle_exception(); } void WritableDatabase::commit() CODE: try { THIS->commit(); } catch (...) { handle_exception(); } void WritableDatabase::begin_transaction(flushed = NO_INIT) bool flushed CODE: try { if (items == 2) { /* items includes the hidden this pointer */ THIS->begin_transaction(flushed); } else { THIS->begin_transaction(); } } catch (...) { handle_exception(); } void WritableDatabase::commit_transaction() CODE: try { THIS->commit_transaction(); } catch (...) { handle_exception(); } void WritableDatabase::cancel_transaction() CODE: try { THIS->cancel_transaction(); } catch (...) { handle_exception(); } docid WritableDatabase::add_document(document) Document * document CODE: try { RETVAL = THIS->add_document(*document); } catch (...) { handle_exception(); } OUTPUT: RETVAL void WritableDatabase::delete_document(did) docid did CODE: try { THIS->delete_document(did); } catch (...) { handle_exception(); } void WritableDatabase::delete_document_by_term(unique_term) string unique_term CODE: try { THIS->delete_document(unique_term); } catch (...) { handle_exception(); } void WritableDatabase::replace_document(did, document) docid did Document * document CODE: try { THIS->replace_document(did, *document); } catch (...) { handle_exception(); } void WritableDatabase::replace_document_by_term(unique_term, document) string unique_term Document * document CODE: try { THIS->replace_document(unique_term, *document); } catch (...) { handle_exception(); } void WritableDatabase::set_metadata(string key, string value) CODE: try { THIS->set_metadata(key, value); } catch (...) { handle_exception(); } void WritableDatabase::DESTROY() void WritableDatabase::add_synonym(string term, string synonym) CODE: try { THIS->add_synonym(term, synonym); } catch (...) { handle_exception(); } void WritableDatabase::remove_synonym(string term, string synonym) CODE: try { THIS->remove_synonym(term, synonym); } catch (...) { handle_exception(); } void WritableDatabase::clear_synonyms(string term) CODE: try { THIS->clear_synonyms(term); } catch (...) { handle_exception(); } void WritableDatabase::add_spelling(word, freqinc = 1) string word termcount freqinc CODE: try { THIS->add_spelling(word, freqinc); } catch (...) { handle_exception(); } void WritableDatabase::remove_spelling(word, freqdec = 1) string word termcount freqdec CODE: try { THIS->remove_spelling(word, freqdec); } catch (...) { handle_exception(); } Search-Xapian-1.2.25.5/XS/Database.xs0000644000175000017500000001062313320553070015521 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::Database PROTOTYPES: ENABLE Database * new1(file) string file CODE: try { RETVAL = new Database(file); } catch (...) { handle_exception(); } OUTPUT: RETVAL Database * new2(database) Database * database CODE: try { RETVAL = new Database(*database); } catch (...) { handle_exception(); } OUTPUT: RETVAL void Database::add_database(database) Database * database CODE: try { THIS->add_database(*database); } catch (...) { handle_exception(); } void Database::reopen() CODE: try { THIS->reopen(); } catch (...) { handle_exception(); } string Database::get_description() CODE: try { RETVAL = THIS->get_description(); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Database::termlist_begin(did) docid did CODE: try { RETVAL = new TermIterator(THIS->termlist_begin(did)); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Database::termlist_end(did) docid did CODE: try { RETVAL = new TermIterator(THIS->termlist_end(did)); } catch (...) { handle_exception(); } OUTPUT: RETVAL PositionIterator * Database::positionlist_begin(did, term) docid did string term CODE: try { RETVAL = new PositionIterator(THIS->positionlist_begin(did, term)); } catch (...) { handle_exception(); } OUTPUT: RETVAL PositionIterator * Database::positionlist_end(did, term) docid did string term CODE: try { RETVAL = new PositionIterator(THIS->positionlist_end(did, term)); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Database::allterms_begin(prefix = NO_INIT) string prefix CODE: try { RETVAL = new TermIterator(THIS->allterms_begin(prefix)); } catch (...) { handle_exception(); } OUTPUT: RETVAL TermIterator * Database::allterms_end(prefix = NO_INIT) string prefix CODE: try { RETVAL = new TermIterator(THIS->allterms_end(prefix)); } catch (...) { handle_exception(); } OUTPUT: RETVAL PostingIterator * Database::postlist_begin(term) string term CODE: try { RETVAL = new PostingIterator(THIS->postlist_begin(term)); } catch (...) { handle_exception(); } OUTPUT: RETVAL PostingIterator * Database::postlist_end(term) string term CODE: try { RETVAL = new PostingIterator(THIS->postlist_end(term)); } catch (...) { handle_exception(); } OUTPUT: RETVAL doccount Database::get_doccount() CODE: try { RETVAL = THIS->get_doccount(); } catch (...) { handle_exception(); } OUTPUT: RETVAL docid Database::get_lastdocid() CODE: try { RETVAL = THIS->get_lastdocid(); } catch (...) { handle_exception(); } OUTPUT: RETVAL doclength Database::get_avlength() CODE: try { RETVAL = THIS->get_avlength(); } catch (...) { handle_exception(); } OUTPUT: RETVAL doccount Database::get_termfreq(tname) string tname CODE: try { RETVAL = THIS->get_termfreq(tname); } catch (...) { handle_exception(); } OUTPUT: RETVAL bool Database::term_exists(tname) string tname CODE: try { RETVAL = THIS->term_exists(tname); } catch (...) { handle_exception(); } OUTPUT: RETVAL termcount Database::get_collection_freq(tname) string tname CODE: try { RETVAL = THIS->get_collection_freq(tname); } catch (...) { handle_exception(); } OUTPUT: RETVAL doclength Database::get_doclength(did) docid did CODE: try { RETVAL = THIS->get_doclength(did); } catch (...) { handle_exception(); } OUTPUT: RETVAL void Database::keep_alive() CODE: try { THIS->keep_alive(); } catch (...) { handle_exception(); } Document * Database::get_document(docid did) CODE: try { RETVAL = new Document(THIS->get_document(did)); } catch (...) { handle_exception(); } OUTPUT: RETVAL string Database::get_spelling_suggestion(word, max_edit_distance = 2) string word int max_edit_distance CODE: try { RETVAL = THIS->get_spelling_suggestion(word, max_edit_distance); } catch (...) { handle_exception(); } OUTPUT: RETVAL string Database::get_metadata(string key) void Database::close() CODE: try { THIS->close(); } catch (...) { handle_exception(); } void Database::DESTROY() Search-Xapian-1.2.25.5/XS/MatchSpy.xs0000644000175000017500000000024713320553070015546 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::MatchSpy PROTOTYPES: ENABLE void MatchSpy::DESTROY() string MatchSpy::name() string MatchSpy::get_description() Search-Xapian-1.2.25.5/XS/WildcardError.xs0000644000175000017500000000041414207005157016560 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::WildcardError PROTOTYPES: ENABLE string WildcardError::get_type() string WildcardError::get_msg() string WildcardError::get_context() const char * WildcardError::get_error_string() void WildcardError::DESTROY() Search-Xapian-1.2.25.5/XS/NetworkError.xs0000644000175000017500000000045214207005157016462 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::NetworkError PROTOTYPES: ENABLE string NetworkError::get_type() string NetworkError::get_msg() string NetworkError::get_context() const char * NetworkError::get_error_string() void NetworkError::DESTROY() INCLUDE: XS/NetworkTimeoutError.xs Search-Xapian-1.2.25.5/XS/DatabaseCorruptError.xs0000644000175000017500000000046614207005157020121 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseCorruptError PROTOTYPES: ENABLE string DatabaseCorruptError::get_type() string DatabaseCorruptError::get_msg() string DatabaseCorruptError::get_context() const char * DatabaseCorruptError::get_error_string() void DatabaseCorruptError::DESTROY() Search-Xapian-1.2.25.5/XS/FeatureUnavailableError.xs0000644000175000017500000000051014207005157020563 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::FeatureUnavailableError PROTOTYPES: ENABLE string FeatureUnavailableError::get_type() string FeatureUnavailableError::get_msg() string FeatureUnavailableError::get_context() const char * FeatureUnavailableError::get_error_string() void FeatureUnavailableError::DESTROY() Search-Xapian-1.2.25.5/XS/DatabaseError.xs0000644000175000017500000000067614207005157016545 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseError PROTOTYPES: ENABLE string DatabaseError::get_type() string DatabaseError::get_msg() string DatabaseError::get_context() const char * DatabaseError::get_error_string() void DatabaseError::DESTROY() INCLUDE: XS/DatabaseCorruptError.xs INCLUDE: XS/DatabaseCreateError.xs INCLUDE: XS/DatabaseLockError.xs INCLUDE: XS/DatabaseModifiedError.xs INCLUDE: XS/DatabaseOpeningError.xs Search-Xapian-1.2.25.5/XS/DatabaseLockError.xs0000644000175000017500000000044414207005157017347 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseLockError PROTOTYPES: ENABLE string DatabaseLockError::get_type() string DatabaseLockError::get_msg() string DatabaseLockError::get_context() const char * DatabaseLockError::get_error_string() void DatabaseLockError::DESTROY() Search-Xapian-1.2.25.5/XS/SerialisationError.xs0000644000175000017500000000045214207005157017637 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::SerialisationError PROTOTYPES: ENABLE string SerialisationError::get_type() string SerialisationError::get_msg() string SerialisationError::get_context() const char * SerialisationError::get_error_string() void SerialisationError::DESTROY() Search-Xapian-1.2.25.5/XS/DatabaseVersionError.xs0000644000175000017500000000046614207005157020110 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::DatabaseVersionError PROTOTYPES: ENABLE string DatabaseVersionError::get_type() string DatabaseVersionError::get_msg() string DatabaseVersionError::get_context() const char * DatabaseVersionError::get_error_string() void DatabaseVersionError::DESTROY() Search-Xapian-1.2.25.5/XS/RuntimeError.xs0000644000175000017500000000103514207005157016452 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::RuntimeError PROTOTYPES: ENABLE string RuntimeError::get_type() string RuntimeError::get_msg() string RuntimeError::get_context() const char * RuntimeError::get_error_string() void RuntimeError::DESTROY() INCLUDE: XS/DatabaseError.xs INCLUDE: XS/DocNotFoundError.xs INCLUDE: XS/FeatureUnavailableError.xs INCLUDE: XS/InternalError.xs INCLUDE: XS/NetworkError.xs INCLUDE: XS/QueryParserError.xs INCLUDE: XS/SerialisationError.xs INCLUDE: XS/RangeError.xs INCLUDE: XS/WildcardError.xs Search-Xapian-1.2.25.5/XS/InvalidOperationError.xs0000644000175000017500000000047414207005157020304 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::InvalidOperationError PROTOTYPES: ENABLE string InvalidOperationError::get_type() string InvalidOperationError::get_msg() string InvalidOperationError::get_context() const char * InvalidOperationError::get_error_string() void InvalidOperationError::DESTROY() Search-Xapian-1.2.25.5/XS/BM25Weight.xs0000644000175000017500000000077613320553070015642 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::BM25Weight PROTOTYPES: ENABLE BM25Weight * new1() CODE: try { RETVAL = new BM25Weight(); } catch (...) { handle_exception(); } OUTPUT: RETVAL BM25Weight * new2(k1, k2, k3, b, min_normlen) double k1 double k2 double k3 double b double min_normlen CODE: try { RETVAL = new BM25Weight(k1, k2, k3, b, min_normlen); } catch (...) { handle_exception(); } OUTPUT: RETVAL void BM25Weight::DESTROY() Search-Xapian-1.2.25.5/XS/Error.xs0000644000175000017500000000042314207005157015106 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::Error PROTOTYPES: ENABLE string Error::get_type() string Error::get_msg() string Error::get_context() const char * Error::get_error_string() void Error::DESTROY() INCLUDE: XS/LogicError.xs INCLUDE: XS/RuntimeError.xs Search-Xapian-1.2.25.5/XS/QueryParser.xs0000644000175000017500000000516213350560532016305 0ustar ollyollyMODULE = Search::Xapian PACKAGE = Search::Xapian::QueryParser PROTOTYPES: ENABLE QueryParser * new0() CODE: RETVAL = XAPIAN_PERL_NEW(QueryParser, ()); OUTPUT: RETVAL void QueryParser::set_stemmer(stemmer) Stem * stemmer CODE: THIS->set_stemmer(*stemmer); void QueryParser::set_stemming_strategy(strategy) int strategy CODE: THIS->set_stemming_strategy(static_cast(strategy)); void QueryParser::set_stopper(stopper) Stopper * stopper CODE: // Keep a reference to the currently set object. XAPIAN_PERL_REF(QueryParser, THIS, stopper, ST(1)); THIS->set_stopper(stopper); void QueryParser::set_default_op(op) int op CODE: THIS->set_default_op(static_cast(op)); int QueryParser::get_default_op() CODE: RETVAL = static_cast(THIS->get_default_op()); OUTPUT: RETVAL void QueryParser::set_database(database) Database * database CODE: THIS->set_database(*database); void QueryParser::set_max_wildcard_expansion(termcount limit) CODE: #if XAPIAN_AT_LEAST(1,5,0) THIS->set_max_expansion(limit, Xapian::Query::WILDCARD_LIMIT_ERROR, Xapian::QueryParser::FLAG_WILDCARD); #else THIS->set_max_wildcard_expansion(limit); #endif Query * QueryParser::parse_query(q, flags = QueryParser::FLAG_DEFAULT) string q int flags CODE: try { RETVAL = new Query(THIS->parse_query(q,flags)); } catch (...) { handle_exception(); } OUTPUT: RETVAL void QueryParser::add_prefix(string field, string prefix) void QueryParser::add_boolean_prefix(string field, string prefix) TermIterator * QueryParser::stoplist_begin() CODE: RETVAL = new TermIterator(THIS->stoplist_begin()); OUTPUT: RETVAL TermIterator * QueryParser::stoplist_end() CODE: RETVAL = new TermIterator(THIS->stoplist_end()); OUTPUT: RETVAL TermIterator * QueryParser::unstem_begin(term) string term CODE: RETVAL = new TermIterator(THIS->unstem_begin(term)); OUTPUT: RETVAL TermIterator * QueryParser::unstem_end(term) string term CODE: RETVAL = new TermIterator(THIS->unstem_end(term)); OUTPUT: RETVAL string QueryParser::get_corrected_query_string() CODE: try { RETVAL = THIS->get_corrected_query_string(); } catch (...) { handle_exception(); } OUTPUT: RETVAL string QueryParser::get_description() void QueryParser::add_valuerangeprocessor(ValueRangeProcessor * vrproc) CODE: // Keep a reference to the currently set object. XAPIAN_PERL_REF(QueryParser, THIS, vrp, ST(1)); THIS->add_valuerangeprocessor(vrproc); void QueryParser::DESTROY() CODE: XAPIAN_PERL_DESTROY(QueryParser, THIS); Search-Xapian-1.2.25.5/Xapian.pm0000644000175000017500000002750013756635130014702 0ustar ollyollypackage Search::Xapian; use 5.006; use strict; use warnings; our $VERSION = '1.2.25.5'; use Exporter 'import'; use Search::Xapian::Database; use Search::Xapian::Document; use Search::Xapian::ESet; use Search::Xapian::ESetIterator; use Search::Xapian::Error; use Search::Xapian::MSet; use Search::Xapian::MSetIterator; use Search::Xapian::MultiValueSorter; use Search::Xapian::PositionIterator; use Search::Xapian::PostingIterator; use Search::Xapian::Query; use Search::Xapian::QueryParser; use Search::Xapian::RSet; use Search::Xapian::Stem; use Search::Xapian::TermGenerator; use Search::Xapian::TermIterator; use Search::Xapian::ValueIterator; use Search::Xapian::WritableDatabase; use Search::Xapian::BM25Weight; use Search::Xapian::BoolWeight; use Search::Xapian::TradWeight; use Search::Xapian::ValueCountMatchSpy; use Search::Xapian::SimpleStopper; use Search::Xapian::PerlStopper; require DynaLoader; our @ISA = qw(DynaLoader); # We need to use the RTLD_GLOBAL flag to dlopen() so that other C++ # modules that link against libxapian.so get the *same* value for all the # weak symbols (eg, the exception classes) sub dl_load_flags { 0x01 } # This allows declaration use Search::Xapian ':all'; # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( 'ops' => [ qw( OP_AND OP_OR OP_AND_NOT OP_XOR OP_AND_MAYBE OP_FILTER OP_NEAR OP_PHRASE OP_VALUE_RANGE OP_SCALE_WEIGHT OP_ELITE_SET OP_VALUE_GE OP_VALUE_LE ) ], 'db' => [ qw( DB_OPEN DB_CREATE DB_CREATE_OR_OPEN DB_CREATE_OR_OVERWRITE ) ], 'enq_order' => [ qw( ENQ_DESCENDING ENQ_ASCENDING ENQ_DONT_CARE ) ], 'qpflags' => [ qw( FLAG_BOOLEAN FLAG_PHRASE FLAG_LOVEHATE FLAG_BOOLEAN_ANY_CASE FLAG_WILDCARD FLAG_PURE_NOT FLAG_PARTIAL FLAG_SPELLING_CORRECTION FLAG_SYNONYM FLAG_AUTO_SYNONYMS FLAG_AUTO_MULTIWORD_SYNONYMS FLAG_DEFAULT ) ], 'qpstem' => [ qw( STEM_NONE STEM_SOME STEM_ALL ) ] ); $EXPORT_TAGS{standard} = [ @{ $EXPORT_TAGS{'ops'} }, @{ $EXPORT_TAGS{'db'} }, @{ $EXPORT_TAGS{'qpflags'} }, @{ $EXPORT_TAGS{'qpstem'} } ]; $EXPORT_TAGS{all} = [ @{ $EXPORT_TAGS{'standard'} }, @{ $EXPORT_TAGS{'enq_order'} }, 'BAD_VALUENO' ]; # Names which can be exported. our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); # Don't export any names by default. our @EXPORT = qw( ); bootstrap Search::Xapian $VERSION; # Preloaded methods go here. our @OP_NAMES; foreach (@{ $EXPORT_TAGS{'ops'} }) { $OP_NAMES[eval $_] = $_; } our @DB_NAMES; foreach (@{ $EXPORT_TAGS{'db'} }) { $DB_NAMES[eval $_] = $_; } our @FLAG_NAMES; foreach (@{ $EXPORT_TAGS{'qpflags'} }) { $FLAG_NAMES[eval $_] = $_; } our @STEM_NAMES; foreach (@{ $EXPORT_TAGS{'qpstem'} }) { $STEM_NAMES[eval $_] = $_; } 1; __END__ =head1 NAME Search::Xapian - Perl XS frontend to the Xapian C++ search library. =head1 SYNOPSIS use Search::Xapian; my $db = Search::Xapian::Database->new( '[DATABASE DIR]' ); my $enq = $db->enquire( '[QUERY TERM]' ); printf "Running query '%s'\n", $enq->get_query()->get_description(); my @matches = $enq->matches(0, 10); print scalar(@matches) . " results found\n"; foreach my $match ( @matches ) { my $doc = $match->get_document(); printf "ID %d %d%% [ %s ]\n", $match->get_docid(), $match->get_percent(), $doc->get_data(); } =head1 DESCRIPTION This module wraps most methods of most Xapian classes. The missing classes and methods should be added in the future. It also provides a simplified, more 'perlish' interface to some common operations, as demonstrated above. There are some gaps in the POD documentation for wrapped classes, but you can read the Xapian C++ API documentation at L for details of these. Alternatively, take a look at the code in the examples and tests. If you want to use Search::Xapian and the threads module together, make sure you're using Search::Xapian >= 1.0.4.0 and Perl >= 5.8.7. As of 1.0.4.0, Search::Xapian uses CLONE_SKIP to make sure that the perl wrapper objects aren't copied to new threads - without this the underlying C++ objects can get destroyed more than once. If you encounter problems, or have any comments, suggestions, patches, etc please email the Xapian-discuss mailing list (details of which can be found at L). =head2 EXPORT None by default. =head1 :db =over 4 =item DB_OPEN Open a database, fail if database doesn't exist. =item DB_CREATE Create a new database, fail if database exists. =item DB_CREATE_OR_OPEN Open an existing database, without destroying data, or create a new database if one doesn't already exist. =item DB_CREATE_OR_OVERWRITE Overwrite database if it exists. =back =head1 :ops =over 4 =item OP_AND Match if both subqueries are satisfied. =item OP_OR Match if either subquery is satisfied. =item OP_AND_NOT Match if left but not right subquery is satisfied. =item OP_XOR Match if left or right, but not both queries are satisfied. =item OP_AND_MAYBE Match if left is satisfied, but use weights from both. =item OP_FILTER Like OP_AND, but only weight using the left query. =item OP_NEAR Match if the words are near each other. The window should be specified, as a parameter to C, but it defaults to the number of terms in the list. =item OP_PHRASE Match as a phrase (All words in order). =item OP_ELITE_SET Select an elite set from the subqueries, and perform a query with these combined as an OR query. =item OP_VALUE_RANGE Filter by a range test on a document value. =back =head1 :qpflags =over 4 =item FLAG_DEFAULT This gives the QueryParser default flag settings, allowing you to easily add flags to the default ones. =item FLAG_BOOLEAN Support AND, OR, etc and bracketed subexpressions. =item FLAG_LOVEHATE Support + and -. =item FLAG_PHRASE Support quoted phrases. =item FLAG_BOOLEAN_ANY_CASE Support AND, OR, etc even if they aren't in ALLCAPS. =item FLAG_WILDCARD Support right truncation (e.g. Xap*). =item FLAG_PURE_NOT Allow queries such as 'NOT apples'. These require the use of a list of all documents in the database which is potentially expensive, so this feature isn't enabled by default. =item FLAG_PARTIAL Enable partial matching. Partial matching causes the parser to treat the query as a "partially entered" search. This will automatically treat the final word as a wildcarded match, unless it is followed by whitespace, to produce more stable results from interactive searches. =item FLAG_SPELLING_CORRECTION =item FLAG_SYNONYM =item FLAG_AUTO_SYNONYMS =item FLAG_AUTO_MULTIWORD_SYNONYMS =back =head1 :qpstem =over 4 =item STEM_ALL Stem all terms. =item STEM_NONE Don't stem any terms. =item STEM_SOME Stem some terms, in a manner compatible with Omega (capitalised words and those in phrases aren't stemmed). =back =head1 :enq_order =over 4 =item ENQ_ASCENDING docids sort in ascending order (default) =item ENQ_DESCENDING docids sort in descending order =item ENQ_DONT_CARE docids sort in whatever order is most efficient for the backend =back =head1 :standard Standard is db + ops + qpflags + qpstem =head1 Version functions =over 4 =item major_version Returns the major version of the Xapian C++ library being used. E.g. for Xapian 1.0.9 this would return 1. =item minor_version Returns the minor version of the Xapian C++ library being used. E.g. for Xapian 1.0.9 this would return 0. =item revision Returns the revision of the Xapian C++ library being used. E.g. for Xapian 1.0.9 this would return 9. In a stable release series, Xapian libraries with the same minor and major versions are usually ABI compatible, so this often won't match the third component of $Search::Xapian::VERSION (which is the version of the Search::Xapian XS wrappers). =back =head1 Numeric encoding functions =over 4 =item sortable_serialise NUMBER Convert a floating point number to a string, preserving sort order. This method converts a floating point number to a string, suitable for using as a value for numeric range restriction, or for use as a sort key. The conversion is platform independent. The conversion attempts to ensure that, for any pair of values supplied to the conversion algorithm, the result of comparing the original values (with a numeric comparison operator) will be the same as the result of comparing the resulting values (with a string comparison operator). On platforms which represent doubles with the precisions specified by IEEE_754, this will be the case: if the representation of doubles is more precise, it is possible that two very close doubles will be mapped to the same string, so will compare equal. Note also that both zero and -zero will be converted to the same representation: since these compare equal, this satisfies the comparison constraint, but it's worth knowing this if you wish to use the encoding in some situation where this distinction matters. Handling of NaN isn't (currently) guaranteed to be sensible. =item sortable_unserialise SERIALISED_NUMBER Convert a string encoded using sortable_serialise back to a floating point number. This expects the input to be a string produced by sortable_serialise(). If the input is not such a string, the value returned is undefined (but no error will be thrown). The result of the conversion will be exactly the value which was supplied to sortable_serialise() when making the string on platforms which represent doubles with the precisions specified by IEEE_754, but may be a different (nearby) value on other platforms. =back =head1 TODO =over 4 =item Error Handling Error handling for all methods liable to generate them. =item Documentation Add POD documentation for all classes, where possible just adapted from Xapian docs. =item Unwrapped classes The following Xapian classes are not yet wrapped: ErrorHandler, standard ExpandDecider subclasses (user-defined ones works), user-defined weight classes. =item Unwrapped methods The following methods are not yet wrapped: Enquire::get_eset(...) with more than two arguments, Query ctor optional "parameter" parameter, Remote::open(...), static Stem::get_available_languages(). We wrap MSet::swap() and MSet::operator[](), but not ESet::swap(), ESet::operator[](). Is swap actually useful? Should we instead tie MSet and ESet to allow them to just be used as lists? =back =head1 CREDITS Thanks to Tye McQueen Etye@metronet.comE for explaining the finer points of how best to write XS frontends to C++ libraries, James Aylett Ejames@tartarus.orgE for clarifying the less obvious aspects of the Xapian API, Tim Brody for patches wrapping ::QueryParser and ::Stopper and especially Olly Betts Eolly@survex.comE for contributing advice, bugfixes, and wrapper code for the more obscure classes. =head1 AUTHOR Alex Bowley Ekilinrax@cpan.orgE Please report any bugs/suggestions to Exapian-discuss@lists.xapian.orgE or use the Xapian bug tracker L. Please do NOT use the CPAN bug tracker or mail any of the authors individually. =head1 LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, and L. =cut Search-Xapian-1.2.25.5/perlobject.map0000644000175000017500000000507713320553070015746 0ustar ollyolly# "perlobject.map" Dean Roehrich, version 19960302 # # TYPEMAPs # # HV * -> unblessed Perl HV object. # AV * -> unblessed Perl AV object. # # INPUT/OUTPUT maps # # O_* -> opaque blessed objects # T_* -> opaque blessed or unblessed objects # # O_OBJECT -> link an opaque C or C++ object to a blessed Perl object. # T_OBJECT -> link an opaque C or C++ object to an unblessed Perl object. # O_HvRV -> a blessed Perl HV object. # T_HvRV -> an unblessed Perl HV object. # O_AvRV -> a blessed Perl AV object. # T_AvRV -> an unblessed Perl AV object. TYPEMAP HV * T_HvRV AV * T_AvRV ###################################################################### OUTPUT # The Perl object is blessed into 'CLASS', which should be a # char* having the name of the package for the blessing. O_OBJECT sv_setref_pv( $arg, CLASS, (void*)$var ); T_OBJECT sv_setref_pv( $arg, Nullch, (void*)$var ); # Cannot use sv_setref_pv() because that will destroy # the HV-ness of the object. Remember that newRV() will increment # the refcount. O_HvRV $arg = sv_bless( newRV((SV*)$var), gv_stashpv(CLASS,1) ); T_HvRV $arg = newRV((SV*)$var); # Cannot use sv_setref_pv() because that will destroy # the AV-ness of the object. Remember that newRV() will increment # the refcount. O_AvRV $arg = sv_bless( newRV((SV*)$var), gv_stashpv(CLASS,1) ); T_AvRV $arg = newRV((SV*)$var); ###################################################################### INPUT O_OBJECT if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } T_OBJECT if( SvROK($arg) ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not an SV reference\" ); XSRETURN_UNDEF; } O_HvRV if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVHV) ) $var = (HV*)SvRV( $arg ); else { warn( \"${Package}::$func_name() -- $var is not a blessed HV reference\" ); XSRETURN_UNDEF; } T_HvRV if( SvROK($arg) && (SvTYPE(SvRV($arg)) == SVt_PVHV) ) $var = (HV*)SvRV( $arg ); else { warn( \"${Package}::$func_name() -- $var is not an HV reference\" ); XSRETURN_UNDEF; } O_AvRV if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVAV) ) $var = (AV*)SvRV( $arg ); else { warn( \"${Package}::$func_name() -- $var is not a blessed AV reference\" ); XSRETURN_UNDEF; } T_AvRV if( SvROK($arg) && (SvTYPE(SvRV($arg)) == SVt_PVAV) ) $var = (AV*)SvRV( $arg ); else { warn( \"${Package}::$func_name() -- $var is not an AV reference\" ); XSRETURN_UNDEF; } Search-Xapian-1.2.25.5/t/0000755000175000017500000000000014207007026013350 5ustar ollyollySearch-Xapian-1.2.25.5/t/document.t0000644000175000017500000000504513643246106015366 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test; use Devel::Peek; BEGIN { plan tests => 26 }; use Search::Xapian qw(:standard); ok(1); # If we made it this far, we're ok. ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. my $doc = Search::Xapian::Document->new(); my $data = "hello world"; $doc->set_data($data); ok( $doc->get_data() eq $data ); $doc->add_value(1, "fudge"); $doc->add_value(2, "chocolate"); ok( $doc->get_value(1) eq "fudge" ); ok( $doc->get_docid() == 0 ); my $it = $doc->values_begin(); ok( $it ne $doc->values_end() ); ok( "$it" eq "fudge" ); ok( $it->get_value() eq "fudge" ); ok( $it->get_valueno() == 1 ); ++$it; ok( $it ne $doc->values_end() ); ok( "$it" eq "chocolate" ); ok( $it->get_value() eq "chocolate" ); ok( $it->get_valueno() == 2 ); ++$it; ok( $it eq $doc->values_end() ); $doc->remove_value(1); ok( $doc->get_value(1) eq "" ); ok( $doc->get_value(2) eq "chocolate" ); $doc->clear_values(); ok( $doc->get_value(2) eq "" ); my $database = Search::Xapian::WritableDatabase->new(); # in <= 0.8.3.0 this added with wdfinc 1 $doc->add_posting( "hello", 1, 100 ); # in <= 0.8.3.0 this added with wdfinc 0 $doc->add_posting( "hello", 2 ); $database->add_document($doc); ok( $database->get_doclength(1) == 101 ); $doc = Search::Xapian::Document->new(); # in <= 0.8.3.0 this added with wdfinc 1 (happens to work as it should) $doc->add_posting( "goodbye", 1, 1 ); # in <= 0.8.3.0 this added with wdfinc 1 (happens to work as it should) $doc->add_posting( "goodbye", 2, 1 ); # in <= 0.8.3.0 this removed with wdfinc 0 $doc->remove_posting( "goodbye", 2 ); $database->add_document($doc); ok( $database->get_doclength(2) == 1 ); $doc = Search::Xapian::Document->new(); # in <= 0.8.3.0 this added with wdfinc 1 $doc->add_term( "a", 100 ); # in <= 0.8.3.0 this added with wdfinc 0 $doc->add_term( "a" ); $database->add_document($doc); ok( $database->get_doclength(3) == 101 ); ok( $it = $doc->termlist_begin()); ok( $it ne $doc->termlist_end()); ok( "$it" eq "a" ); ok( $it->get_termname() eq "a" ); ++$it; ok( $it eq $doc->termlist_end()); $doc->add_boolean_term( "b" ); $database->add_document($doc); ok( $database->get_doclength(4) == 101 ); $doc->remove_term( "a" ); $database->add_document($doc); ok( $database->get_doclength(5) == 0 ); 1; Search-Xapian-1.2.25.5/t/index.t0000644000175000017500000001073313643246106014657 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More; BEGIN { plan tests => 117 }; use Search::Xapian qw(:standard); ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. foreach my $backend ("inmemory", "auto") { my $database; if ($backend eq "inmemory") { ok( $database = Search::Xapian::WritableDatabase->new() ); } else { ok( $database = Search::Xapian::WritableDatabase->new( 'testdb', Search::Xapian::DB_CREATE_OR_OVERWRITE ) ); } ok( $database->get_description() ); my $stemmer; ok( $stemmer = Search::Xapian::Stem->new( 'english' ) ); ok( $stemmer->get_description() ); my %docs; my $term = 'test'; ok( $term = $stemmer->stem_word( $term ) ); if ($backend ne "inmemory") { # inmemory doesn't implement spelling correction support. $database->add_spelling( $term, 1 ); } my $docid; for my $num (qw( one two three )) { ok( $docs{$num} = Search::Xapian::Document->new() ); ok( $docs{$num}->get_description() ); $docs{$num}->set_data( "$term $num" ); $docs{$num}->add_posting( $term, 0 ); $docs{$num}->add_posting( $num, 1 ); $docs{$num}->add_value(0, $num); if ($backend ne "inmemory") { # inmemory doesn't implement spelling correction support. $database->add_spelling( "x" . $term, 1 ); $database->add_spelling( $term, 1 ); $database->remove_spelling( "x" . $term, 1 ); } ok( $docid = $database->add_document( $docs{$num} ) ); } $database->delete_document( $docid ); is( $database->get_doccount(), 2 ); is( $database->get_lastdocid(), 3 ); is( $database->get_document(1)->get_docid(), 1 ); is( $database->get_document(2)->get_docid(), 2 ); # regression test - add_posting with 2 parameters set wdfinc 0 in <=0.8.3.0 ok( $database->get_doclength(1) == 2 ); is( $database->get_document(1)->get_value(0), "one" ); is( $database->get_document(2)->get_value(0), "two" ); my $posit = $database->positionlist_begin(1, $term); ok( $posit ne $database->positionlist_end(1, $term) ); ok( $posit == 0 ); $posit++; ok( $posit eq $database->positionlist_end(1, $term) ); my $postit = $database->postlist_begin('one'); ok( $postit ne $database->postlist_end('one') ); ok( $postit != $database->postlist_end('one') ); is( $postit->get_docid(), 1 ); $postit++; ok( $postit eq $database->postlist_end('one') ); ok( $postit == $database->postlist_end('one') ); my $termit = $database->termlist_begin(1); ok( $termit != $database->termlist_end(1) ); is( "$termit", 'one' ); $termit++; ok( $termit ne $database->termlist_end(1) ); is( $termit->get_termname(), 'test' ); ++$termit; ok( $termit eq $database->termlist_end(1) ); ok( $termit == $database->termlist_end(1) ); my $alltermit = $database->allterms_begin(); ok( $alltermit != $database->allterms_end() ); ok( "$alltermit" eq 'one' ); ok( $alltermit->get_termname() eq 'one' ); ok( ++$alltermit != $database->allterms_end() ); ok( "$alltermit" eq 'test' ); ok( $alltermit->get_termname() eq 'test' ); ok( ++$alltermit != $database->allterms_end() ); ok( "$alltermit" eq 'two' ); ok( $alltermit->get_termname() eq 'two' ); ok( ++$alltermit == $database->allterms_end() ); $alltermit = $database->allterms_begin('t'); ok( $alltermit != $database->allterms_end('t') ); ok( "$alltermit" eq 'test' ); ok( $alltermit->get_termname() eq 'test' ); ok( ++$alltermit != $database->allterms_end('t') ); ok( "$alltermit" eq 'two' ); ok( $alltermit->get_termname() eq 'two' ); ok( ++$alltermit == $database->allterms_end('t') ); # Feature test for metadata support. is( $database->get_metadata( "nothing" ), "" ); is( $database->get_metadata( "foo" ), "" ); $database->set_metadata( "foo", "bar" ); is( $database->get_metadata( "nothing" ), "" ); is( $database->get_metadata( "foo" ), "bar" ); } # Check that trying to create an invalid stemmer gives an exception, not an # abort. eval { my $badstem = Search::Xapian::Stem->new( 'gibberish' ); }; ok($@); ok(ref($@), "Search::Xapian::InvalidArgumentError"); ok($@->isa('Search::Xapian::Error')); ok($@->get_msg, "Language code gibberish unknown"); ok( "$@" =~ /^Exception: Language code gibberish unknown(?: at \S+ line \d+\.)?$/ ); 1; Search-Xapian-1.2.25.5/t/tied.t0000644000175000017500000000334113643246106014472 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test; use Devel::Peek; BEGIN { plan tests => 22 }; use Search::Xapian qw(:ops); ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. # None of the following tests can be expected to succeed without first # creating a test database in the directory testdb. my $db = Search::Xapian::Database->new( 'testdb' ); my $enq = Search::Xapian::Enquire->new( $db ); my $query = Search::Xapian::Query->new( 'test' ); $enq->set_query( $query ); my $mset; ok( $mset = $enq->get_mset(0, 10) ); my @matches; ok( @matches = $mset->items() ); my $match; ok( $match = $matches[0] ); ok( $match->get_docid() ); ok( $match->get_percent() ); $matches[0] = 34; my $doc; ok( $doc = $match->get_document() ); ok( $doc->get_data() ); ok( exists $matches[1] ); ok( !exists $matches[10] ); ok( exists $matches[-1] ); # Test that "tying by hand" still works. sub tie_mset { my @a; tie( @a, 'Search::Xapian::MSet::Tied', shift ); return @a; } ok( $mset = $enq->get_mset(0, 1) ); ok( scalar(tie_mset($mset)) == 1 ); my @ematches; ok( @ematches = $enq->matches(0, 2) ); ok( $match = $ematches[0] ); ok( $match->get_docid() ); ok( $match->get_percent() ); my $eset; my $rset; ok( $rset = Search::Xapian::RSet->new() ); $rset->add_document( 1 ); ok( $eset = $enq->get_eset( 10, $rset ) ); ok( $eset->size() != 0 ); my @eterms; ok( @eterms = $eset->items() ); ok( scalar @eterms == $eset->size() ); ok( $eterms[0]->get_termname() eq $eset->begin()->get_termname() ); 1; Search-Xapian-1.2.25.5/t/thread.t0000644000175000017500000001671713643246106015027 0ustar ollyolly#!/usr/bin/perl use strict; use warnings qw(all); # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More; if ($] < 5.008007) { # Perl 5.8.7 added CLONE_SKIP which is required to implement the behaviour # which this test case tests. plan skip_all => 'Test requires Perl >= 5.8.7 for CLONE_SKIP'; } eval { require threads; }; if ($@) { plan skip_all => 'Test requires Perl with thread support'; } # Number of test cases to run - increase this if you add more testcases. plan tests => 65; use Search::Xapian qw(:standard); # TODO: check these classes too: # MSet/Tied.pm # PerlStopper.pm # Stopper.pm # Weight.pm my ($wdb, $db, $doc, $bm25wt, $boolwt, $tradwt, $enq, $qp, $q, $stem); my ($eset, $mset, $rset, $esetit, $msetit, $postit, $posit, $termit, $valueit); my ($sstop, $tg); sub thread_proc { # Check that calling a method fails, and that it isn't a Xapian object. eval { $wdb->get_doccount(); }; return 0 unless $@ && ref($wdb) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $db->get_doccount(); }; return 0 unless $@ && ref($db) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $doc->get_data(); }; return 0 unless $@ && ref($doc) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($bm25wt) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($boolwt) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($tradwt) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $enq->get_query(); }; return 0 unless $@ && ref($enq) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $qp->get_default_op(); }; return 0 unless $@ && ref($qp) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $q->empty(); }; return 0 unless $@ && ref($q) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $stem->stem_word("testing"); }; return 0 unless $@ && ref($stem) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $eset->empty(); }; return 0 unless $@ && ref($eset) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $mset->empty(); }; return 0 unless $@ && ref($mset) !~ 'Xapian'; # Check that calling a method fails, and that it isn't a Xapian object. eval { $rset->empty(); }; return 0 unless $@ && ref($rset) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($esetit) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($msetit) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($postit) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($posit) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($termit) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($valueit) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($sstop) !~ 'Xapian'; # Check that it isn't a Xapian object. return 0 unless ref($tg) !~ 'Xapian'; } ok( $wdb = Search::Xapian::WritableDatabase->new(), 'create WritableDatabase' ); is( $wdb->get_doccount(), 0, 'check WritableDatabase' ); ok( $db = Search::Xapian::Database->new('testdb'), 'create Database' ); is( $db->get_doccount(), 2, 'check Database' ); ok( $doc = $db->get_document(1), 'create Document' ); is( $doc->get_data(), 'test one', 'check Document' ); ok( $bm25wt = Search::Xapian::BM25Weight->new(), 'create BM25Weight' ); is( ref($bm25wt), 'Search::Xapian::BM25Weight', 'check BM25Weight' ); ok( $boolwt = Search::Xapian::BoolWeight->new(), 'create BoolWeight' ); is( ref($boolwt), 'Search::Xapian::BoolWeight', 'check BoolWeight' ); ok( $tradwt = Search::Xapian::TradWeight->new(), 'create TradWeight' ); is( ref($tradwt), 'Search::Xapian::TradWeight', 'check TradWeight' ); ok( $enq = Search::Xapian::Enquire->new($db), 'create Enquire' ); ok( $enq->get_query()->empty(), 'check Enquire' ); ok( $qp = Search::Xapian::QueryParser->new(), 'create QueryParser' ); is( $qp->get_default_op(), OP_OR, 'check QueryParser' ); ok( $q = $qp->parse_query("foo"), 'create Query' ); ok( !$q->empty(), 'check Query' ); ok( $stem = Search::Xapian::Stem->new('en'), 'create Stem' ); is( $stem->stem_word('testing'), 'test', 'check Stem' ); ok( $eset = Search::Xapian::ESet->new(), 'create ESet' ); ok( $eset->empty(), 'check ESet' ); ok( $mset = Search::Xapian::MSet->new(), 'create MSet' ); ok( $mset->empty(), 'check MSet' ); ok( $rset = Search::Xapian::RSet->new(), 'create RSet' ); ok( $rset->empty(), 'check RSet' ); ok( $esetit = $eset->begin(), 'create ESetIterator' ); is( ref($esetit), 'Search::Xapian::ESetIterator', 'check ESetIterator' ); ok( $msetit = $mset->begin(), 'create MSetIterator' ); is( ref($msetit), 'Search::Xapian::MSetIterator', 'check MSetIterator' ); ok( $postit = $db->postlist_begin("one"), 'create PostingIterator' ); is( ref($postit), 'Search::Xapian::PostingIterator', 'check PostingIterator' ); ok( $posit = $db->positionlist_begin(1, "one"), 'create PositionIterator' ); is( ref($posit), 'Search::Xapian::PositionIterator', 'check PositionIterator' ); ok( $termit = $db->termlist_begin(1), 'create TermIterator' ); is( ref($termit), 'Search::Xapian::TermIterator', 'check TermIterator' ); ok( $valueit = $doc->values_begin(), 'create ValueIterator' ); is( $valueit->get_valueno(), 0, 'check ValueIterator' ); ok( $sstop = Search::Xapian::SimpleStopper->new(), 'create SimpleStopper' ); is( ref($sstop), 'Search::Xapian::SimpleStopper', 'check SimpleStopper' ); ok( $tg = Search::Xapian::TermGenerator->new(), 'create TermGenerator' ); is( ref($tg), 'Search::Xapian::TermGenerator', 'check TermGenerator' ); my $thread1 = threads->create(sub { thread_proc(); }); my $thread2 = threads->create(sub { thread_proc(); }); ok( $thread1->join, 'check thread1' ); ok( $thread2->join, 'check thread2' ); is( $wdb->get_doccount(), 0, 'check WritableDatabase' ); is( $db->get_doccount(), 2, 'check Database' ); is( $doc->get_data(), 'test one', 'check Document' ); is( ref($bm25wt), 'Search::Xapian::BM25Weight', 'check BM25Weight' ); is( ref($boolwt), 'Search::Xapian::BoolWeight', 'check BoolWeight' ); is( ref($tradwt), 'Search::Xapian::TradWeight', 'check TradWeight' ); ok( $enq->get_query()->empty(), 'check Enquire' ); is( $qp->get_default_op(), OP_OR, 'check QueryParser' ); ok( !$q->empty(), 'check Query' ); is( $stem->stem_word('testing'), 'test', 'check Stem' ); ok( $eset->empty(), 'check ESet' ); ok( $mset->empty(), 'check MSet' ); ok( $rset->empty(), 'check RSet' ); is( ref($esetit), 'Search::Xapian::ESetIterator', 'check ESetIterator' ); is( ref($msetit), 'Search::Xapian::MSetIterator', 'check MSetIterator' ); is( ref($postit), 'Search::Xapian::PostingIterator', 'check PostingIterator' ); is( ref($posit), 'Search::Xapian::PositionIterator', 'check PositionIterator' ); is( ref($termit), 'Search::Xapian::TermIterator', 'check TermIterator' ); is( $valueit->get_valueno(), 0, 'check ValueIterator' ); is( ref($sstop), 'Search::Xapian::SimpleStopper', 'check SimpleStopper' ); is( ref($tg), 'Search::Xapian::TermGenerator', 'check TermGenerator' ); Search-Xapian-1.2.25.5/t/sorter.t0000644000175000017500000000554513643246106015073 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More; use Devel::Leak; BEGIN { plan tests => 40 }; use Search::Xapian qw(:all); ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. sub mset_expect_order (\@@) { my ($m, @a) = @_; my @m = map { $_->get_docid() } @{$m}; is( scalar @m, scalar @a ); for my $j (0 .. (scalar @a - 1)) { is( $m[$j], $a[$j] ); } } my $db; ok( $db = Search::Xapian::WritableDatabase->new(), "test db opened ok" ); my $enquire; ok( $enquire = Search::Xapian::Enquire->new( $db ), "enquire object created" ); my $doc; ok( $doc = Search::Xapian::Document->new() ); $doc->add_term("foo"); $doc->add_value(0, "ABB"); $db->add_document($doc); $doc->add_value(0, "ABC"); $db->add_document($doc); $doc->add_value(0, "ABC\0"); $db->add_document($doc); $doc->add_value(0, "ABCD"); $db->add_document($doc); $doc->add_value(0, "ABC\xff"); $db->add_document($doc); $enquire->set_query(Search::Xapian::Query->new("foo")); { { my $sorter = Search::Xapian::MultiValueSorter->new(); $sorter->add(0); $enquire->set_sort_by_key($sorter); } my @matches = $enquire->matches(0, 10); mset_expect_order(@matches, (5, 4, 3, 2, 1)); } { my $sorter = Search::Xapian::MultiValueSorter->new(); $sorter->add(0, 0); $enquire->set_sort_by_key($sorter); my @matches = $enquire->matches(0, 10); mset_expect_order(@matches, (1, 2, 3, 4, 5)); } { my $sorter = Search::Xapian::MultiValueSorter->new(); $sorter->add(0); $sorter->add(1); $enquire->set_sort_by_key($sorter); my @matches = $enquire->matches(0, 10); mset_expect_order(@matches, (5, 4, 3, 2, 1)); } { my $sorter = Search::Xapian::MultiValueSorter->new(); $sorter->add(0, 0); $sorter->add(1); $enquire->set_sort_by_key($sorter); my @matches = $enquire->matches(0, 10); mset_expect_order(@matches, (1, 2, 3, 4, 5)); } { my $sorter = Search::Xapian::MultiValueSorter->new(); $sorter->add(0); $sorter->add(1, 0); $enquire->set_sort_by_key($sorter); my @matches = $enquire->matches(0, 10); mset_expect_order(@matches, (5, 4, 3, 2, 1)); } { my $sorter = Search::Xapian::MultiValueSorter->new(); $sorter->add(0, 0); $sorter->add(1, 0); $enquire->set_sort_by_key($sorter); my @matches = $enquire->matches(0, 10); mset_expect_order(@matches, (1, 2, 3, 4, 5)); } my $handle; my $count = Devel::Leak::NoteSV($handle); { my $enq = Search::Xapian::Enquire->new($db); $enq->set_sort_by_key(Search::Xapian::MultiValueSorter->new(3, 1, 4)); } ok( $count == Devel::Leak::CheckSV($handle) ); 1; Search-Xapian-1.2.25.5/t/symbol-test/0000755000175000017500000000000014207007026015632 5ustar ollyollySearch-Xapian-1.2.25.5/t/symbol-test/SymbolTest.pm0000644000175000017500000000061713320553070020301 0ustar ollyollypackage SymbolTest; use strict; use warnings; use vars qw( $VERSION @ISA ); $VERSION = '1.2.3.0'; require DynaLoader; @ISA = qw( DynaLoader ); # We need to use the RTLD_GLOBAL flag to dlopen() so that other C++ # modules that link against libxapian.so get the *same* value for all the # weak symbols (eg, the exception classes) #### sub dl_load_flags { 0x01 } bootstrap SymbolTest $VERSION; 1; Search-Xapian-1.2.25.5/t/symbol-test/SymbolTest.xs0000644000175000017500000000070213320553070020312 0ustar ollyolly#include extern "C" { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" } MODULE = SymbolTest PACKAGE = SymbolTest PROTOTYPES: ENABLE void throw_from_libxapian() CODE: try { Xapian::WritableDatabase db("/dev/null", Xapian::DB_CREATE_OR_OPEN); } catch (const Xapian::Error & error) { croak("%s caught in SymbolTest", error.get_type()); } catch (...) { croak("Unknown C++ exception caught in SymbolTest"); } Search-Xapian-1.2.25.5/t/symbol-test/typemap0000644000175000017500000000047213320553070017237 0ustar ollyollyTYPEMAP SymbolTest * O_OBJECT OUTPUT O_OBJECT sv_setref_pv( $arg, CLASS, (void*)$var ); INPUT O_OBJECT if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } Search-Xapian-1.2.25.5/t/symbol-test/Makefile.PL0000644000175000017500000001154413320553070017611 0ustar ollyollyuse ExtUtils::MakeMaker; use strict; use Config; # Suppress warnings about parameters we allow the user to specify. $ExtUtils::MakeMaker::Recognized_Att_Keys{CPPFLAGS} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{CXX} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{CXXFLAGS} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{XAPIAN_CONFIG} = 1; my $builddir; my $srcdir = $0; if ($srcdir =~ s!/([^/]*)$!!) { # Set $0 to be just the leafname. If we don't, WriteMakefile() reruns this # script for reasons unknown, leading to a seemingly infinite loop # consuming increasing amounts of memory. With setting $0, it still reruns # this script, but only once. $0 = $1; chomp($builddir = `pwd`); chdir $srcdir; } my $xapian_config; my $CC; my %var = (); for (@ARGV) { if (/^XAPIAN_CONFIG=(.*)/) { $xapian_config = $1; } elsif (/^CXX=(.*)/) { $CC = $1; } elsif (/^(C(?:XX|PP)FLAGS)=(.*)/) { $var{$1} = $2; } } if (!defined $xapian_config && exists $ENV{XAPIAN_CONFIG}) { $xapian_config = $ENV{XAPIAN_CONFIG}; push @ARGV, "XAPIAN_CONFIG=$xapian_config"; } $xapian_config ||= 'xapian-config'; if (!defined $CC && exists $ENV{CXX}) { $CC = $ENV{CXX}; push @ARGV, "CXX=$CC"; } $CC ||= 'g++'; my $LD = '$(CC)'; if ($^O eq 'cygwin' and $CC eq 'g++') { # Cygwin packages of Perl < 5.9.5 used "ld2" for $Config{ld} and # $Config{lddlflags} didn't contain -shared so we need to specify # this explicitly. Perl >= 5.9.5 package do away with "ld2", but # it should be harmless to specify "-shared" there. $LD = 'g++ -shared'; } my $xver = `$xapian_config --version`; if ($xver eq '') { print STDERR < "1.2.0" my $inc = `$xapian_config --cxxflags`; chomp($inc); my @writemakefile_args = (); my $libsvar = 'LIBS'; my $libs = `$xapian_config --libs 2> /dev/null`; chomp($libs); my ($xapian_config_dir) = $xapian_config =~ /^(.*?)[^\/]*$/; if ($? || ($xapian_config_dir ne '' && -f "${xapian_config_dir}Makefile")) { # Assume we're being asked to build against an uninstalled xapian-core. my $libtool = "${xapian_config_dir}libtool"; unless (-x $libtool) { die "You've asked me to link against what appears to be an uninstalled xapian-core tree, but I can't find libtool in that tree\n"; } # We can't pass a .la file in LIBS since MakeMaker "knows better" and # ignores it. Passing it in LDLOADLIBS works, but generates a warning. # We can avoid the warning by setting LDLOADLIBS using 'macro'. $libsvar = 'macro'; $libs = `$xapian_config --ltlibs`; chomp($libs); $libs = {'LDLOADLIBS' => $libs}; $LD = "$libtool --tag=CXX --mode=link $CC -avoid-version -module"; $LD .= " -rpath \$(PERL_ARCHLIB)/auto/\$(FULLEXT)"; $LD .= " -shrext .".$Config{'dlext'}; $CC = "$libtool --tag=CXX --mode=compile $CC"; push @writemakefile_args, ( 'OBJ_EXT' => '.lo', 'DLEXT' => 'la', 'FULLPERL' => '$(PERL) "-I$(INST_ARCHAUTODIR)/.libs"', ); } # Filter out some gcc options which g++ doesn't support. my $CCFLAGS = $Config{'ccflags'}; # Perl is built with -Wdeclaration-after-statement on RHEL5 - this isn't # meaningful for C++ - it only emits a warning but it's easy to fix. $CCFLAGS =~ s/(?:^|\s+)-Wdeclaration-after-statement(?:\s+|$)/ /; # The generated code causes "variable may be used uninitialized" warnings # if Perl was built with -Wall. $CCFLAGS =~ s/(^|\s+)-Wall(\s+|$)/$1-Wall -Wno-uninitialized$2/; $CCFLAGS .= ' ' . $var{CPPFLAGS} if exists $var{CPPFLAGS}; $CCFLAGS .= ' ' . $var{CXXFLAGS} if exists $var{CXXFLAGS}; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. push @writemakefile_args, ( 'NAME' => 'SymbolTest', 'VERSION_FROM' => 'SymbolTest.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 $libsvar => $libs, # e.g., '-lm' 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' 'CC' => $CC, 'CCFLAGS' => $CCFLAGS, 'LD' => $LD, 'INC' => $inc, # e.g., '-I/usr/include/other' 'OBJECT' => '$(BASEEXT)$(OBJ_EXT)', 'XSOPT' => '-C++', ); WriteMakefile(@writemakefile_args); Search-Xapian-1.2.25.5/t/parser.t0000644000175000017500000001537313754605456015063 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test; use Devel::Leak; use Devel::Peek; BEGIN { plan tests => 62 }; use Search::Xapian qw(:standard); ok(1); # If we made it this far, we're ok. ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. # Adjust query description from 1.4 to match. sub qd { local $_ = (shift @_)->get_description(); if (substr($_, 0, 1) eq 'Q') { s/\@([0-9]+)/:(pos=$1)/g; s/\\x([0-9a-f]{2})/chr(hex($1))/ge; s/^Query\(0 \* VALUE_RANGE/Query(VALUE_RANGE/; $_ = "Xapian::$_"; } return $_; } # first create database dir, if it doesn't exist; my $db_dir = 'testdb'; my $database; ok( $database = Search::Xapian::Database->new( $db_dir ) ); my $qp = new Search::Xapian::QueryParser( $database ); $qp = new Search::Xapian::QueryParser(); $qp->set_stemmer( Search::Xapian::Stem->new('english') ); $qp->set_stemming_strategy( STEM_ALL ); $qp->set_default_op( OP_AND ); my $query; ok( $query = $qp->parse_query( 'one or two', FLAG_BOOLEAN|FLAG_BOOLEAN_ANY_CASE|FLAG_SPELLING_CORRECTION ) ); ok( not $qp->get_corrected_query_string()); ok( qd($query), "Xapian::Query((one:(pos=1) OR two:(pos=2)))" ); ok( $query = $qp->parse_query( 'one OR (two AND three)' ) ); ok( qd($query), "Xapian::Query((one:(pos=1) OR (two:(pos=2) AND three:(pos=3))))" ); ok( my $enq = $database->enquire( $query ) ); { my @stopwords = qw(a the in on and); my $stopper; ok( $stopper = new Search::Xapian::SimpleStopper(@stopwords) ); foreach (@stopwords) { ok( $stopper->stop_word($_) ); } foreach (qw(one two three four five)) { ok( !$stopper->stop_word($_) ); } ok( $qp->set_stopper($stopper), undef ); } ok( $qp->parse_query("one two many") ); $qp = new Search::Xapian::QueryParser(); my $vrp; ok( $vrp = new Search::Xapian::StringValueRangeProcessor(1) ); $qp->add_valuerangeprocessor($vrp); $qp->add_boolean_prefix("test", "XTEST"); my $handle; my $count = Devel::Leak::NoteSV($handle); { my $qp2 = new Search::Xapian::QueryParser(); $qp2->add_valuerangeprocessor( Search::Xapian::StringValueRangeProcessor->new(1, 'test:', 1)); $qp2->set_stopper(Search::Xapian::SimpleStopper->new(qw(a an the))); $qp2->set_stopper(Search::Xapian::SimpleStopper->new(qw(a the))); } ok( $count == Devel::Leak::CheckSV($handle) ); my $pair; foreach $pair ( [ 'a..b', 'VALUE_RANGE 1 a b' ], [ '$50..100', 'VALUE_RANGE 1 $50 100' ], [ '$50..$99', 'VALUE_RANGE 1 $50 $99' ], [ '02/03/1979..10/12/1980', 'VALUE_RANGE 1 02/03/1979 10/12/1980' ], [ 'a..b hello', '(hello:(pos=1) FILTER VALUE_RANGE 1 a b)' ], [ 'hello a..b', '(hello:(pos=1) FILTER VALUE_RANGE 1 a b)' ], [ 'hello a..b world', '((hello:(pos=1) OR world:(pos=2)) FILTER VALUE_RANGE 1 a b)' ], [ 'hello a..b test:foo', '(hello:(pos=1) FILTER (VALUE_RANGE 1 a b AND XTESTfoo))' ], [ '-5..7', 'VALUE_RANGE 1 -5 7' ], [ 'hello -5..7', '(hello:(pos=1) FILTER VALUE_RANGE 1 -5 7)' ], [ '-5..7 hello', '(hello:(pos=1) FILTER VALUE_RANGE 1 -5 7)' ], [ '"time flies" 09:00..12:30', '((time:(pos=1) PHRASE 2 flies:(pos=2)) FILTER VALUE_RANGE 1 09:00 12:30)' ] ) { my ($str, $res) = @{$pair}; my $query = $qp->parse_query($str); ok( qd($query), "Xapian::Query($res)" ); } $qp = new Search::Xapian::QueryParser(); my $vrp1 = new Search::Xapian::DateValueRangeProcessor(1); my $vrp2 = new Search::Xapian::NumberValueRangeProcessor(2); my $vrp3 = new Search::Xapian::StringValueRangeProcessor(3); my $vrp4 = new Search::Xapian::NumberValueRangeProcessor(4, '$'); my $vrp5 = new Search::Xapian::NumberValueRangeProcessor(5, 'kg', 0); my $vrp6 = new Search::Xapian::StringValueRangeProcessor(6, 'country:'); my $vrp7 = new Search::Xapian::StringValueRangeProcessor(7, ':name', 0); $qp->add_valuerangeprocessor( $vrp1 ); $qp->add_valuerangeprocessor( $vrp2 ); $qp->add_valuerangeprocessor( $vrp4 ); $qp->add_valuerangeprocessor( $vrp5 ); $qp->add_valuerangeprocessor( $vrp6 ); $qp->add_valuerangeprocessor( $vrp7 ); $qp->add_valuerangeprocessor( $vrp3 ); $qp->add_boolean_prefix("test", "XTEST"); foreach $pair ( [ 'a..b', 'VALUE_RANGE 3 a b' ], [ '1..12', "VALUE_RANGE 2 \xa0 \xae" ], [ '20070201..20070228', 'VALUE_RANGE 1 20070201 20070228' ], [ '$10..20', "VALUE_RANGE 4 \xad \xb1" ], [ '$10..$20', "VALUE_RANGE 4 \xad \xb1" ], [ '12..42kg', "VALUE_RANGE 5 \xae \xb5@" ], [ '12kg..42kg', "VALUE_RANGE 5 \xae \xb5@" ], [ '12kg..42', 'VALUE_RANGE 3 12kg 42' ], [ '!10..$20', 'VALUE_RANGE 3 !10 $20' ], [ '1999-03-12..2020-12-30', 'VALUE_RANGE 1 19990312 20201230' ], [ '1999/03/12..2020/12/30', 'VALUE_RANGE 1 19990312 20201230' ], [ '1999.03.12..2020.12.30', 'VALUE_RANGE 1 19990312 20201230' ], [ '12/03/99..12/04/01', 'VALUE_RANGE 1 19990312 20010412' ], [ '03-12-99..04-14-01', 'VALUE_RANGE 1 19990312 20010414' ], [ '(test:a..test:b hello)', '(hello:(pos=1) FILTER VALUE_RANGE 3 test:a test:b)' ], [ 'country:chile..denmark', 'VALUE_RANGE 6 chile denmark' ], [ 'albert..xeni:name', 'VALUE_RANGE 7 albert xeni' ], ) { my ($str, $res) = @{$pair}; my $query = $qp->parse_query($str); skip(substr($str, 0, 1) eq '!' && Search::Xapian::major_version() == 1 && Search::Xapian::minor_version() == 2 && Search::Xapian::revision() < 21 ? "Testcase requires xapian-core >= 1.2.21" : 0, qd($query), "Xapian::Query($res)" ); } $qp = new Search::Xapian::QueryParser(); { my $vrpdate = new Search::Xapian::DateValueRangeProcessor(1, 1, 1960); $qp->add_valuerangeprocessor( $vrpdate ); } foreach $pair ( [ '12/03/99..12/04/01', 'VALUE_RANGE 1 19991203 20011204' ], [ '03-12-99..04-14-01', 'VALUE_RANGE 1 19990312 20010414' ], [ '01/30/60..02/02/59', 'VALUE_RANGE 1 19600130 20590202' ], ) { my ($str, $res) = @{$pair}; my $query = $qp->parse_query($str); ok( qd($query), "Xapian::Query($res)" ); } # Regression test for Search::Xapian bug fixed in 1.0.5.0. In 1.0.0.0-1.0.4.0 # we tried to catch const char * not Xapian::Error, so std::terminate got # called. $qp = Search::Xapian::QueryParser->new; eval { $qp->parse_query('other* AND', FLAG_BOOLEAN|FLAG_WILDCARD); }; ok($@); ok(ref($@), "Search::Xapian::QueryParserError", "correct class for exception"); ok($@->isa('Search::Xapian::Error')); ok($@->get_msg, "Syntax: AND ", "get_msg works"); ok( $@ =~ /^Exception: Syntax: AND (?: at \S+ line \d+\.)?$/ ); # Check FLAG_DEFAULT is wrapped (new in 1.0.11.0). ok( $qp->parse_query('hello world', FLAG_DEFAULT|FLAG_BOOLEAN_ANY_CASE) ); # Check BAD_VALUENO is wrapped. ok( Search::Xapian::BAD_VALUENO != 0 ); 1; Search-Xapian-1.2.25.5/t/writabledatabase.t0000644000175000017500000001533413643246106017050 0ustar ollyolly#!/usr/bin/perl use strict; use warnings qw(all); # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More; # Number of test cases to run - increase this if you add more testcases. plan tests => 42; use Search::Xapian qw(:standard); my $db_dir = 'testdb-writabledatabase'; # Delete contents of database dir, if it exists. if (opendir( DB_DIR, $db_dir )) { while( defined( my $file = readdir( DB_DIR ) ) ) { next if $file =~ /^\.+$/; unlink( "$db_dir/$file" ) or die "Could not delete '$db_dir/$file': $!"; } closedir( DB_DIR ); } my $write = Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE ); # Let's try to index something. my $term = 'test'; for my $num (1..1000) { my $doc = Search::Xapian::Document->new(); $doc->set_data( "$term $num" ); $doc->add_posting( $term, 0 ); $doc->add_posting( $num, 1 ); $doc->add_value(0, $num); $write->add_document( $doc ); } for my $num (qw(three four five)) { my $doc = Search::Xapian::Document->new(); $doc->set_data( "$term $num" ); $doc->add_posting( $term, 0 ); $doc->add_posting( $num, 1 ); $doc->add_value(0, $num); $write->add_document( $doc ); } $write->flush(); my $doccount = $write->get_doccount(); is($doccount, 1003, "check number of documents in WritableDatabase"); # replace document by docid my $repdoc = Search::Xapian::Document->new(); my $num = "six"; $term = "test"; my $docid = 500; $repdoc->set_data( "$term $num" ); $repdoc->add_posting( $term, 0 ); $repdoc->add_posting( $num, 1 ); $repdoc->add_value(0, $num); ok(!$write->term_exists($num), "check term exists"); is($write->get_document($docid)->get_data(), "$term $docid", "check document data"); $write->replace_document($docid, $repdoc); $write->flush(); $write->keep_alive(); ok($write->term_exists($num), "check term exists"); is($write->get_document($docid)->get_data(), "$term $num", "check document data"); is($write->get_collection_freq($term), 1003, "check term frequency"); is($write->get_avlength(), 2, "check term frequency"); # replace document by term $repdoc = Search::Xapian::Document->new(); $term = "test"; $num = "seven"; $repdoc->set_data( "$term $num" ); $repdoc->add_posting( $term, 0 ); $repdoc->add_posting( $num, 1 ); $repdoc->add_value(0, $num); my $repterm = "five"; ok(!$write->term_exists($num), "check term exists"); ok($write->term_exists($repterm), "check term exists"); is($write->get_termfreq($num), 0, "check term frequency"); is($write->get_termfreq($repterm), 1, "check term frequency"); $write->replace_document_by_term($repterm, $repdoc); $write->flush(); ok($write->term_exists($num), "check term exists"); ok(!$write->term_exists($repterm), "check term exists"); is($write->get_termfreq($num), 1, "check term frequency"); is($write->get_termfreq($repterm), 0, "check term frequency"); # replace document by term, if term is new $repdoc = Search::Xapian::Document->new(); $term = "test"; $num = "eight"; $repdoc->set_data( "$term $num" ); $repdoc->add_posting( $term, 0 ); $repdoc->add_posting( $num, 1 ); $repdoc->add_value(0, $num); is($write->get_termfreq($term), $doccount, "check term frequency"); is($write->get_termfreq($num), 0, "check term frequency"); $write->replace_document_by_term($num, $repdoc); $write->flush(); $doccount = $write->get_doccount(); is($doccount, 1004, "check doccount"); is($write->get_termfreq($term), $doccount, "check term frequency"); is($write->get_termfreq($num), 1, "check term frequency"); # replace document by term. # all documents indexed with the term are replaced; the replacement uses the # lowest docid if multiple documents are indexed by the term. $repdoc = Search::Xapian::Document->new(); $term = "test"; $num = "nine"; $repdoc->set_data( "$term $num" ); $repdoc->add_posting( $term, 0 ); $repdoc->add_posting( $num, 1 ); $repdoc->add_value(0, $num); $write->replace_document_by_term($term, $repdoc); $write->flush(); my $doc = $write->get_document(1); is($write->get_doccount(), 1, "check document count"); is($doc->get_data(), "$term $num", "check document data"); # add documents for following tests for my $num (qw(one two three four five)) { my $doc = Search::Xapian::Document->new(); $doc->set_data( "$term $num" ); $doc->add_posting( $term, 0 ); $doc->add_posting( $num, 1 ); $doc->add_value(0, $num); $write->add_document( $doc ); } $write->flush(); $doccount = $write->get_doccount(); is($doccount, 6, "check number of documents in WritableDatabase"); # delete document by docid my $lastdocid = $write->get_lastdocid(); my $lastdocterm = $write->get_document($lastdocid)->get_value(0); ok($write->term_exists($lastdocterm), "check term exists"); $write->delete_document($lastdocid); $write->flush(); is($write->get_doccount(), $doccount - 1, "check number of documents in WritableDatabase"); ok(!$write->term_exists($lastdocterm), "check term exists"); # delete document by term my $delterm = 'three'; ok($write->term_exists($delterm), 'check term exists before deleting a document'); is($write->get_termfreq($delterm), 1, 'check term frequency before deleting a document'); $write->delete_document_by_term($delterm); $write->flush(); is($write->get_doccount(), $doccount - 2, 'check WritableDatabase after deleting a document'); ok(!$write->term_exists($delterm), 'check term exists after deleting a document'); is($write->get_termfreq($delterm), 0, 'check term frequency after deleting a document'); # delete documents by term $delterm = 'test'; ok($write->term_exists($delterm), 'check term exists of documents which has term "test"'); is($write->get_termfreq($delterm), $doccount - 2, 'check term frequency of term "test"'); $write->delete_document_by_term($delterm); $write->flush(); is($write->get_doccount(), 0, 'check WritableDatabase after deleting all documents'); ok(!$write->term_exists($delterm), 'check term exists after deleting all documents'); is($write->get_termfreq($delterm), 0, 'check term frequency after deleting all documents'); eval { # Should fail because the database is already open for writing. Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE_OR_OPEN ); }; ok( $@ ); $write->close(); eval { # Should fail because the database has been closed. $write->add_document(Search::Xapian::Document->new()); }; ok( $@ ); # Should work now. ok( Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE_OR_OPEN ) ); # And reference counting should have closed it. ok( Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE_OR_OPEN ) ); my $read = Search::Xapian::Database->new( $db_dir ); ok( $@ ); $read->close(); eval { # Should fail because the database has been closed. $write->allterms_begin(); }; ok( $@ ); 1; Search-Xapian-1.2.25.5/t/valuerange.t0000644000175000017500000000421713643246106015701 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More; BEGIN { plan tests => 22 }; use Search::Xapian qw(:all); ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. # None of the following tests can be expected to succeed without first # creating a test database in the directory testdb. my $db; ok( $db = Search::Xapian::Database->new( 'testdb' ), "test db opened ok" ); my $enq; ok( $enq = Search::Xapian::Enquire->new( $db ), "enquire object created" ); my $query; my $mset; ok( $query = Search::Xapian::Query->new(OP_VALUE_RANGE, 0, "a", "b") ); $enq->set_query($query); ok( $mset = $enq->get_mset(0, 10), "got mset" ); is( $mset->size, 0, "range a..b ok" ); ok( $query = Search::Xapian::Query->new(OP_VALUE_RANGE, 0, "four", "seven") ); $enq->set_query($query); ok( $mset = $enq->get_mset(0, 10), "got mset" ); is( $mset->size, 1, "range four..seven ok" ); is( $mset->begin()->get_document()->get_value(0), "one" ); ok( $query = Search::Xapian::Query->new(OP_VALUE_RANGE, 0, "one", "zero") ); $enq->set_query($query); ok( $mset = $enq->get_mset(0, 10), "got mset" ); is( $mset->size, 2, "range one..zero ok" ); my $mseti = $mset->begin(); is( $mseti->get_document()->get_value(0), "one" ); ++$mseti; is( $mseti->get_document()->get_value(0), "two" ); ok( $query = Search::Xapian::Query->new(OP_VALUE_LE, 0, "one") ); $enq->set_query($query); ok( $mset = $enq->get_mset(0, 10), "got mset" ); # FIXME: bug in xapian-core in 1.0.6 and earlier means this gives the wrong answer #is( $mset->size, 1, "range ..one ok" ); ok( 1 ); $mseti = $mset->begin(); is( $mseti->get_document()->get_value(0), "one" ); ok( $query = Search::Xapian::Query->new(OP_VALUE_GE, 0, "two") ); $enq->set_query($query); ok( $mset = $enq->get_mset(0, 10), "got mset" ); is( $mset->size, 1, "range one.. ok" ); $mseti = $mset->begin(); is( $mseti->get_document()->get_value(0), "two" ); 1; Search-Xapian-1.2.25.5/t/10query.t0000644000175000017500000000252213643246106015053 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More; BEGIN { plan tests => 10 }; use Search::Xapian qw(:standard); use Config; ok(1); # If we made it this far, we're ok. ######################### # Adjust query description from 1.4 to match. sub qd { local $_ = (shift @_)->get_description(); if (substr($_, 0, 1) eq 'Q') { s/\@([0-9]+)/:(pos=$1)/g; $_ = "Xapian::$_"; } return $_; } my $query = Search::Xapian::Query->new( OP_AND, Search::Xapian::Query->new( "foo" ), "bar" ); ok(defined $query, "AND query created"); is(qd($query), 'Xapian::Query((foo AND bar))', "AND query contains foo part"); $query = Search::Xapian::Query::MatchAll; is(qd($query), 'Xapian::Query()'); $query = Search::Xapian::Query->new(""); is(qd($query), 'Xapian::Query()'); $query = Search::Xapian::Query::MatchNothing; is(qd($query), 'Xapian::Query()'); $query = Search::Xapian::Query->new(); is(qd($query), 'Xapian::Query()'); eval { Search::Xapian::Query->new("hello", 1, 2, 3, 4); }; ok(defined $@, "Bad query ctor threw exception"); like($@, qr!^USAGE: Search::Xapian::Query->new\('term'\) or Search::Xapian::Query->new\(OP, \) at \S+/10query\.t line \d+\.?$!); ok(1); Search-Xapian-1.2.25.5/t/search.t0000644000175000017500000001777513754605456015044 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More; BEGIN { plan tests => 122 }; use Search::Xapian qw(:ops); ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. # None of the following tests can be expected to succeed without first # creating a test database in the directory testdb. # Adjust query description from 1.4 to match. sub qd { local $_ = (shift @_)->get_description(); if (substr($_, 0, 1) eq 'Q') { s/\@([0-9]+)/:(pos=$1)/g; s/^Query\(0 \* VALUE_RANGE/Query(VALUE_RANGE/; $_ = "Xapian::$_"; } return $_; } my $db; ok( $db = Search::Xapian::Database->new( 'testdb' ), "test db opened ok" ); my $enq; ok( $enq = $db->enquire(), "db enquirable" ); my @subqueries; my $query; ok( $subqueries[0] = Search::Xapian::Query->new( 'test' ), "one-term queries ok" ); is( qd($subqueries[0]), "Xapian::Query(test)", "query parsed correctly" ); # tests 5-14 foreach my $op (OP_OR, OP_AND, OP_NEAR, OP_PHRASE) { ok( $query = Search::Xapian::Query->new( $op, @subqueries ), "$Search::Xapian::OP_NAMES[$op] works with 1 object" ); ok( $query = Search::Xapian::Query->new( $op, 'help' ), "$Search::Xapian::OP_NAMES[$op] works with 1 term" ); } is( qd($query), "Xapian::Query(help)", "query parsed correctly" ); # tests 15-41 $subqueries[1] = Search::Xapian::Query->new( 'help' ); foreach my $op (OP_OR, OP_AND, OP_NEAR, OP_PHRASE, OP_AND_NOT, OP_XOR, OP_AND_MAYBE, OP_FILTER, OP_ELITE_SET) { ok( $query = Search::Xapian::Query->new( $op, @subqueries ), "$Search::Xapian::OP_NAMES[$op] works with 2 objects" ); ok( $query = Search::Xapian::Query->new( $op, $subqueries[0], 'test'), "$Search::Xapian::OP_NAMES[$op] works with an object and a term" ); ok( $query = Search::Xapian::Query->new( $op, 'test', 'help'), "$Search::Xapian::OP_NAMES[$op] works with 2 terms" ); } is( qd($query), "Xapian::Query((test ELITE_SET 10 help))", "query parsed correctly" ); # tests 42-... $subqueries[2] = Search::Xapian::Query->new( 'one' ); foreach my $op (OP_OR, OP_AND, OP_NEAR, OP_PHRASE ) { ok( $query = Search::Xapian::Query->new( $op, @subqueries ), "$Search::Xapian::OP_NAMES[$op] works with 3 objects" ); ok( $query = Search::Xapian::Query->new( $op, 'test', 'help', 'one' ), "$Search::Xapian::OP_NAMES[$op] works with 3 terms" ); } is( qd($query), "Xapian::Query((test PHRASE 3 help PHRASE 3 one))", "query parsed correctly" ); ok( $enq = $db->enquire( $query ), "db queries return ok" ); ok( $enq = $db->enquire( OP_OR, 'test', 'help' ), "in-line db queries return ok" ); is( $db->get_spelling_suggestion( 'tost' ), 'test', "spelling suggestion ok" ); ok( $query = Search::Xapian::Query->new(OP_SCALE_WEIGHT, $query, 3.14), "OP_SCALE_WEIGHT understood" ); my $matches; ok( $matches = $enq->get_mset( 0, 10 ), "match set returned ok" ); is( $matches->get_matches_estimated(), 2, "match set contains correct number of results" ); my $matches2; ok( $matches2 = $enq->get_mset( 0, 1, 3 ), "match set with check_at_least returned ok" ); is( $matches2->get_matches_estimated(), 2, "match set contains correct number of results" ); my $match; ok( $match = $matches->begin(), "match set iterator returned ok" ); is( $match, $matches->begin(), "match set returns consistent start point"); ok( $match++, "match set iterator can increment" ); isnt( $match, $matches->begin(), "match set iterator increments correctly" ); ok( $match->get_docid(), "document id returned ok" ); ok( $match->get_percent(), "percent relevance returned ok" ); is( $match->get_percent(), $matches->convert_to_percent($match->get_weight()), "converting a weight to a percentage works" ); is( $match->get_percent(), $matches->convert_to_percent($match), "converting an MSetIterator to a percentage works" ); my $doc; ok( $doc = $match->get_document(), "documents retrievable" ); ok( $doc->get_data(), "data retrievable" ); ok( $match--, "match set iterator can decrement" ); is( $match, $matches->begin(), "match set iterator decrements correctly" ); for (1 .. $matches->size()) { $match++; } is( $match, $matches->end(), "match set returns correct endpoint"); my $rset; ok( $rset = Search::Xapian::RSet->new(), "relevance set created ok" ); $rset->add_document( 1 ); ok( $rset->contains( 1 ), "document added to relevance set successfully" ); ok( !$rset->contains( 2 ), "relevance set correctly fails to match document it does not contain" ); $rset->remove_document( 1 ); ok( !$rset->contains( 1 ), "document removed from relevance set successfully" ); $rset->add_document( 1 ); my $matches3; ok( $matches3 = $enq->get_mset(0, 10, $rset), "get_mset with rset" ); is( $matches3->size, $matches->size, "rset doesn't change mset size" ); ok( $matches3 = $enq->get_mset(0, 10, 11, $rset), "get_mset with check_at_least and rset" ); is( $matches3->size, $matches->size, "rset and check_at_least don't change mset size" ); my $d; # This was generating a warning converting "0" to an RSet object: ok( $matches3 = $enq->get_mset(0, 10, sub { $d = scalar @_; return $_[0]->get_value(0) ne ""; }), "get_mset with matchdecider" ); ok( defined $d, "matchdecider was called" ); ok( $d == 1, "matchdecider got an argument" ); sub mdecider { $d = scalar @_; return $_[0]->get_value(0) ne ""; } $d = undef; ok( $matches3 = $enq->get_mset(0, 10, \&mdecider), "get_mset with named matchdecider function" ); ok( defined $d, "matchdecider was called" ); ok( $d == 1, "matchdecider got an argument" ); my $eset; ok( $eset = $enq->get_eset( 10, $rset ), "can get expanded terms set" ); is( $eset->size(), 1, "expanded terms set of correct size" ); my $eit; ok( $eit = $eset->begin(), "expanded terms set iterator retuns ok" ); is( $eit->get_termname(), 'one', "expanded terms set contains correct terms"); is( ++$eit, $eset->end(), "eset iterator reaches ESet::end() ok" ); --$eit; is( $eit->get_termname(), 'one', "eset iterator decrement works ok" ); ok( $eset = $enq->get_eset( 10, $rset, sub { $_[0] ne "one" } ), "expanded terms set with decider" ); is( $eset->size(), 0, "expanded terms decider filtered" ); # try an empty mset - this was giving begin != end my ($noquery, $nomatches); ok( $noquery = Search::Xapian::Query->new( OP_AND_NOT, 'test', 'test' ), "matchless query returns ok" ); $enq->set_query( $noquery ); ok( $nomatches = $enq->get_mset( 0, 10 ), "matchless query returns match set ok" ); is( $nomatches->size(), 0, "matchless query's match set has zero size" ); is( $nomatches->begin(), $nomatches->end(), "matchless query's match set's start point and endpoint are the same" ); ok( $matches->convert_to_percent(100) > 0 ); ok( $matches->convert_to_percent( $matches->begin() ) > 0 ); $match = $matches->back(); --$match; ++$match; ok( $match eq $matches->back() ); ok( $match->get_collapse_count() == 0 ); my $bm25; ok( $bm25 = Search::Xapian::BM25Weight->new() ); my $boolweight; ok( $boolweight = Search::Xapian::BoolWeight->new() ); my $tradweight; ok( $tradweight = Search::Xapian::TradWeight->new() ); my $alltermit = $db->allterms_begin(); ok( $alltermit != $db->allterms_end() ); ok( "$alltermit" eq 'one' ); ok( $alltermit->get_termname() eq 'one' ); ok( ++$alltermit != $db->allterms_end() ); ok( "$alltermit" eq 'test' ); ok( $alltermit->get_termname() eq 'test' ); ok( ++$alltermit != $db->allterms_end() ); ok( "$alltermit" eq 'two' ); ok( $alltermit->get_termname() eq 'two' ); ok( ++$alltermit == $db->allterms_end() ); $alltermit = $db->allterms_begin('t'); ok( $alltermit != $db->allterms_end('t') ); ok( "$alltermit" eq 'test' ); ok( $alltermit->get_termname() eq 'test' ); ok( ++$alltermit != $db->allterms_end('t') ); ok( "$alltermit" eq 'two' ); ok( $alltermit->get_termname() eq 'two' ); ok( ++$alltermit == $db->allterms_end('t') ); # Check that non-string scalars get coerced. my $numberquery = Search::Xapian::Query->new( OP_OR, (12, "34", .5) ); is( qd($numberquery), "Xapian::Query((12 OR 34 OR 0.5))" ); 1; Search-Xapian-1.2.25.5/t/04functions.t0000644000175000017500000000271013643246106015720 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More; BEGIN { plan tests => 26 }; use Search::Xapian qw(:standard); use Config; ok(1); # If we made it this far, we're ok. ######################### # Test non-class functions. my $version = join(".", ( Search::Xapian::major_version(), Search::Xapian::minor_version(), Search::Xapian::revision() )); ok($version eq Search::Xapian::version_string()); my $ldbl = (defined($Config{uselongdouble}) && $Config{uselongdouble} eq "define" && $Config{doublesize} != $Config{longdblsize}); for my $val (-9e10, -1234.56, -1, -1e-10, 0, 1e-10, 1, 2, 4, 8, 9, 9e10) { my $enc_val = Search::Xapian::sortable_serialise($val); if ($ldbl) { # Perl is configured with -Duselongdouble and long double isn't the # same as double, so we may have rounded the input value slightly # passing it to Xapian. my $de_enc_val = Search::Xapian::sortable_unserialise($enc_val); ok(abs($de_enc_val - $val) < 1e-12); # But encoding and decoding the value we got back should give exactly # the same value. my $re_enc_val = Search::Xapian::sortable_serialise($de_enc_val); ok(Search::Xapian::sortable_unserialise($re_enc_val) == $de_enc_val); } else { # We should get the exact same value back. ok(Search::Xapian::sortable_unserialise($enc_val) == $val); ok(1); } } 1; Search-Xapian-1.2.25.5/t/01use.t0000644000175000017500000000034113643246106014477 0ustar ollyollyuse strict; use Test::More tests => 3; use_ok('Search::Xapian'); # Check that module's version is defined and has a sane value. ok(defined($Search::Xapian::VERSION)); ok($Search::Xapian::VERSION =~ /^\d+\.\d+\.\d+\.\d+$/); Search-Xapian-1.2.25.5/t/facets.t0000644000175000017500000000346513643246106015021 0ustar ollyollyuse Test::More; BEGIN { plan tests => 12 }; use Search::Xapian qw(:all); my $db = Search::Xapian::WritableDatabase->new(); { my $i = 0; for my $q (qw( low high high )) { my $doc = Search::Xapian::Document->new(); $doc->set_data("test t$i $q"); $doc->add_posting("test", 0); $doc->add_posting("t$i", 1); $doc->add_posting($q, 2); $doc->add_value(0, $q); $db->add_document($doc); $i++; } my $spy; ok( $spy = Search::Xapian::ValueCountMatchSpy->new(0), "ValueCountMatchSpy created ok" ); my $enq; ok( $enq = $db->enquire('test'), "db enquirable" ); $enq->add_matchspy($spy); is( $spy->name(), "Xapian::ValueCountMatchSpy", "match spy corretly identified as Xapian::ValueCountMatchSpy" ); my $mset = $enq->get_mset(0, 10, 10000); note $spy->get_description(); is( $spy->get_total(), 3, "match spy went through correct number of documents" ); my $ref = [ { name => "high", freq => 2 }, { name => "low" , freq => 1 }, ]; my $it; ok( $it = $spy->values_begin(), "values iterator properly returned from match spy" ); $i = 0; for (my $it = $spy->values_begin(); $it != $spy->values_end(); $it++) { is( $it->get_termname(), $ref->[$i]->{name}, "Term iterator index $i was '" . $ref->[$i]->{name} . "' as expected" ); is( $it->get_termfreq(), $ref->[$i]->{freq}, "Correct frequency for index $i"); $i++; } ok( $it = $spy->top_values_begin(1), "top values iterator properly returned from match spy" ); is( $it->get_termname(), $ref->[0]->{name}, "top value is indeed '" . $ref->[0]->{name} . "' as returned by top values iterator" ); $enq->clear_matchspies(); is( $spy->get_total(), 3, "clearing matchspies doesn't kill our spy reference?" ); } Search-Xapian-1.2.25.5/t/databasemodified.t0000644000175000017500000000427513643246106017021 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test; use Devel::Peek; BEGIN { plan tests => 6 }; use Search::Xapian qw(:standard); ok(1); # If we made it this far, we're ok. ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. # first create database dir, if it doesn't exist; my $db_dir = 'testdb-exception-modified'; if( (! -e $db_dir) or (! -d $db_dir) ) { mkdir( $db_dir ); } opendir( DB_DIR, $db_dir ); while( defined( my $file = readdir( DB_DIR ) ) ) { next if $file =~ /^\.+$/; unlink( "$db_dir/$file" ) or die "Could not delete '$db_dir/$file': $!"; } closedir( DB_DIR ); my $create = Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE ); $create = undef; my $read = Search::Xapian::Database->new( $db_dir ); my $write = Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE_OR_OPEN ); my $enq = $read->enquire(OP_OR, "test"); # Let's try to index something. my $term = 'test'; my $docid; for my $num (1..1000) { my $doc = Search::Xapian::Document->new(); $doc->set_data( "$term $num" ); $doc->add_posting( $term, 0 ); $doc->add_posting( $num, 1 ); $doc->add_value(0, $num); $write->add_document( $doc ); } $write->flush(); $read->reopen(); for my $num (qw(three four five)) { my $doc = Search::Xapian::Document->new(); $doc->set_data( "$term $num" ); $doc->add_posting( $term, 0 ); $doc->add_posting( $num, 1 ); $doc->add_value(0, $num); $write->add_document( $doc ); $write->flush(); } $write->flush(); eval { my $mset = $enq->get_mset(0, 10); }; ok($@); ok(ref($@), "Search::Xapian::DatabaseModifiedError", "correct class for exception"); ok($@->isa('Search::Xapian::Error')); ok($@->get_msg, "The revision being read has been discarded - you should call Xapian::Database::reopen() and retry the operation", "get_msg works"); # WritableDatabase::reopen() is a no-op, but it shouldn't fail. $write->reopen(); ok(1); 1; Search-Xapian-1.2.25.5/t/03podcoverage.t0000644000175000017500000000042713643246106016210 0ustar ollyollyuse strict; use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; plan skip_all => 'set TEST_POD_COVERAGE to enable this test' unless $ENV{TEST_POD_COVERAGE}; all_pod_coverage_ok({also_private => [qr/[^\d][0123]$/]}); Search-Xapian-1.2.25.5/t/02pod.t0000644000175000017500000000031213643246106014464 0ustar ollyollyuse strict; use Test::More; eval "use Test::Pod 1.14"; plan skip_all => 'Test::Pod 1.14 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_files_ok(); Search-Xapian-1.2.25.5/t/collapse.t0000644000175000017500000000307713643246106015355 0ustar ollyollyuse strict; # Before 'make install' is performed this script should be runnable with # 'make test'. After 'make install' it should work as 'perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; # Make warnings fatal use warnings; BEGIN {$SIG{__WARN__} = sub { die "Terminating test due to warning: $_[0]" } }; use Test::More; BEGIN { plan tests => 8 }; use Search::Xapian qw(:all); ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. sub mset_expect_order (\@@) { my ($m, @a) = @_; my @m = map { $_->get_docid() } @{$m}; is( scalar @m, scalar @a ); for my $j (0 .. (scalar @a - 1)) { is( $m[$j], $a[$j] ); } } my $db; ok( $db = Search::Xapian::WritableDatabase->new(), "test db opened ok" ); my $enquire; ok( $enquire = Search::Xapian::Enquire->new( $db ), "enquire object created" ); my $doc; ok( $doc = Search::Xapian::Document->new() ); $doc->add_value(0, "A"); $doc->add_term("foo"); $db->add_document($doc); $doc->add_term("foo"); $db->add_document($doc); $doc->add_term("foo"); $db->add_document($doc); $doc->add_term("foo"); $db->add_document($doc); $doc->add_term("foo"); $db->add_document($doc); $enquire->set_query(Search::Xapian::Query->new("foo")); { $enquire->set_collapse_key(0); my @matches = $enquire->matches(0, 3); mset_expect_order(@matches, (5)); } { $enquire->set_collapse_key(0, 2); my @matches = $enquire->matches(0, 3); mset_expect_order(@matches, (5, 4)); } 1; Search-Xapian-1.2.25.5/t/symbol-test.t0000644000175000017500000000220613643246106016026 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More; BEGIN { plan tests => 3 }; my ($srcdir) = ($0 =~ m!(.*/)!); chdir("${srcdir}symbol-test") or die $!; open ARGS, "../../makefile-pl-args" or die $!; my @args = ; close ARGS; chomp @args; # Avoid inheriting values with Search/Xapian path in. delete $ENV{LD}; delete $ENV{MAKEFLAGS}; system($^X, "Makefile.PL", @args) == 0 or die $!; system("make 2>&1") == 0 or die $!; use lib ( # For shared objects when built with uninstalled xapian-core (libtool): "blib/arch/auto/SymbolTest/.libs", # For shared objects when built with installed xapian-core (no libtool): "blib/arch/auto/SymbolTest", # For .pm files: "blib/lib" ); use_ok("SymbolTest"); eval { SymbolTest::throw_from_libxapian() }; like( $@, qr/DatabaseOpeningError caught in SymbolTest/, 'Correct exception caught'); use Search::Xapian qw( :all ); eval { SymbolTest::throw_from_libxapian() }; like( $@, qr/DatabaseOpeningError caught in SymbolTest/, 'Correct exception caught'); 1; Search-Xapian-1.2.25.5/t/create.t0000644000175000017500000000155113643246106015011 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test::More; BEGIN { plan tests => 4 }; use Search::Xapian qw(:standard); ok(1); # If we made it this far, we're ok. ######################### my $db_dir = 'testdb'; # Delete contents of database dir, if it exists. if (opendir( DB_DIR, $db_dir )) { while( defined( my $file = readdir( DB_DIR ) ) ) { next if $file =~ /^\.+$/; unlink( "$db_dir/$file" ) or die "Could not delete '$db_dir/$file': $!"; } closedir( DB_DIR ); } is( $Search::Xapian::DB_NAMES[Search::Xapian::DB_CREATE], "DB_CREATE" ); my $database; ok( $database = Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE ) ); ok( $database = Search::Xapian::WritableDatabase->new() ); 1; Search-Xapian-1.2.25.5/t/termgenerator.t0000644000175000017500000000501313643246106016421 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### use Test; use Devel::Leak; use Devel::Peek; BEGIN { plan tests => 29 }; use Search::Xapian qw(:standard); ok(1); # If we made it this far, we're ok. ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. # first create database dir, if it doesn't exist; my $termgen = new Search::Xapian::TermGenerator(); my $doc = new Search::Xapian::Document(); $termgen->set_document($doc); $termgen->index_text('foo bar baz foo'); $termgen->index_text_without_positions('baz zoo'); my $ti = $doc->termlist_begin(); ok( $ti ne $doc->termlist_end()); ok( $ti->get_termname(), 'bar' ); ok( $ti->get_wdf(), 1 ); my $pi = $ti->positionlist_begin(); ok( $pi ne $ti->positionlist_end() ); ok( $pi->get_termpos(), 2 ); ok( ++$pi, $ti->positionlist_end() ); ok( ++$ti ne $doc->termlist_end()); ok( $ti->get_termname(), 'baz' ); ok( $ti->get_wdf(), 2 ); $pi = $ti->positionlist_begin(); ok( $pi ne $ti->positionlist_end() ); ok( $pi->get_termpos(), 3 ); ok( ++$pi, $ti->positionlist_end() ); ok( ++$ti ne $doc->termlist_end() ); ok( $ti->get_termname(), 'foo' ); ok( $ti->get_wdf(), 2 ); $pi = $ti->positionlist_begin(); ok( $pi ne $ti->positionlist_end() ); ok( $pi->get_termpos(), 1 ); ok( ++$pi ne $ti->positionlist_end() ); ok( $pi->get_termpos(), 4 ); ok( ++$pi, $ti->positionlist_end() ); ok( ++$ti ne $doc->termlist_end() ); ok( $ti->get_termname(), 'zoo' ); ok( $ti->get_wdf(), 1 ); $pi = $ti->positionlist_begin(); ok( $pi, $ti->positionlist_end() ); ok( ++$ti eq $doc->termlist_end() ); my $db = Search::Xapian::WritableDatabase->new("testdb-spell", DB_CREATE_OR_OVERWRITE); ok( $db ); my $indexer = Search::Xapian::TermGenerator->new(); $indexer->set_flags(Search::Xapian::FLAG_SPELLING); $indexer->set_database($db); my $document = Search::Xapian::Document->new(); $indexer->set_document($document); $indexer->index_text('test hello'); $termgen->index_text('foo bar baz foo', 4); $termgen->index_text_without_positions('baz zoo', 42); ok( $db->add_document($document) ); undef $db; my $handle; my $count = Devel::Leak::NoteSV($handle); { my $tg = new Search::Xapian::TermGenerator(); $tg->set_stopper(Search::Xapian::SimpleStopper->new(qw(a an the))); $tg->set_stopper(Search::Xapian::SimpleStopper->new(qw(a the))); } ok( $count, Devel::Leak::CheckSV($handle) ); 1; Search-Xapian-1.2.25.5/t/exception.t0000644000175000017500000000346313754614063015554 0ustar ollyollyuse strict; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test; use Devel::Peek; BEGIN { plan tests => 6 }; use Search::Xapian qw(:standard); ok(1); # If we made it this far, we're ok. ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. # first create database dir, if it doesn't exist; my $db_dir = 'testdb-exception'; if( (! -e $db_dir) or (! -d $db_dir) ) { mkdir( $db_dir ); } opendir( DB_DIR, $db_dir ); while( defined( my $file = readdir( DB_DIR ) ) ) { next if $file =~ /^\.+$/; unlink( "$db_dir/$file" ) or die "Could not delete '$db_dir/$file': $!"; } closedir( DB_DIR ); my $database; ok( $database = Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE ) ); eval { # this should work my $other_database = Search::Xapian::Database->new( $db_dir ); }; ok( !$@ ); eval { # should fail because database is already locked my $other_database = Search::Xapian::WritableDatabase->new( $db_dir, Search::Xapian::DB_CREATE ); }; ok( $@ ); # Check that our exception list includes exceptions new in 1.4.x. # Regression test for bug fixed in 1.2.25.3. my $doc = Search::Xapian::Document->new(); $doc->add_term("foo"); $doc->add_term("food"); $database->add_document($doc); my $qp = Search::Xapian::QueryParser->new(); $qp->set_max_wildcard_expansion(1); my $enquire = Search::Xapian::Enquire->new($database); eval { my $query = $qp->parse_query('fo*', FLAG_WILDCARD); $enquire->set_query($query); my $mset = $enquire->get_mset(0, 10); }; ok( $@ ); ok( $@ !~ /something terrible happened/); 1; Search-Xapian-1.2.25.5/Xapian/0000755000175000017500000000000014207007026014325 5ustar ollyollySearch-Xapian-1.2.25.5/Xapian/SerialisationError.pm0000644000175000017500000000072114207005157020506 0ustar ollyollypackage Search::Xapian::SerialisationError; =head1 NAME Search::Xapian::SerialisationError - Indicates an error in the std::string serialisation of an object. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/MatchSpy.pm0000644000175000017500000000351113320553070016413 0ustar ollyollypackage Search::Xapian::MatchSpy; use 5.006; use strict; use warnings; # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } 1; __END__ =head1 NAME Search::Xapian::MatchSpy - abstract base class for match spies. =head1 DESCRIPTION This is an abstract base class for match spies in Xapian. The subclasses will generally accumulate information seen during the match, to calculate aggregate functions, or other profiles of the matching documents. =head1 METHODS =over 4 =item operator() Virtual - needs to be implemented in extending classes. Registers a document with the match spy. This is called by the matcher once with each document seen by the matcher during the match process. Note that the matcher will often not see all the documents which match the query, due to optimisations which allow low-weighted documents to be skipped, and allow the match process to be terminated early. =item get_description Return a string describing this object. This default implementation returns a generic answer, to avoid forcing those deriving their own MatchSpy subclasses from having to implement this (they may not care what get_description() gives for their subclass). Reimplemented in Xapian::ValueCountMatchSpy. =item name Return the name of this match spy. This name is used by the remote backend. It is passed with the serialised parameters to the remote server so that it knows which class to create. Return the full namespace-qualified name of your class here. If you don't want to support the remote backend in your match spy, you can use the default implementation which simply throws Xapian::UnimplementedError. Reimplemented in Xapian::ValueCountMatchSpy. =back =head1 SEE ALSO L, L, L =cut Search-Xapian-1.2.25.5/Xapian/WritableDatabase.pm0000644000175000017500000001425113320553070020064 0ustar ollyollypackage Search::Xapian::WritableDatabase; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader Search::Xapian::Database); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '=' => sub { $_[0]->clone() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $database; my $invalid_args; if( scalar(@_) == 1 ) { my $arg = shift; my $arg_class = ref( $arg ); if( $arg_class eq $class ) { $database = new2( $arg ); } else { $invalid_args = 1; } } elsif( scalar(@_) == 2 ) { $database = new1( @_ ); } elsif( scalar(@_) == 0 ) { $database = new3(); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(\$file, DB_OPTS), $class->new(\$database), $class->new()" ); exit; } bless $database, $class; return $database; } 1; __END__ =head1 NAME Search::Xapian::WritableDatabase - writable database object =head1 DESCRIPTION This class represents a Xapian database for indexing. It's a subclass of L, which is used for searching. =head1 METHODS =over 4 =item new or new Class constructor. Takes either a database object, or a path and one of DB_OPEN, DB_CREATE, DB_CREATE_OR_OPEN or DB_CREATE_OR_OVERWRITE. These are exported by L with the 'db' option. =item clone Return a clone of this class. =item flush Flush to disk any modifications made to the database. For efficiency reasons, when performing multiple updates to a database it is best (indeed, almost essential) to make as many modifications as memory will permit in a single pass through the database. To ensure this, Xapian batches up modifications. Flush may be called at any time to ensure that the modifications which have been made are written to disk: if the flush succeeds, all the preceding modifications will have been written to disk. If any of the modifications fail, an exception will be thrown and the database will be left in a state in which each separate addition, replacement or deletion operation has either been fully performed or not performed at all: it is then up to the application to work out which operations need to be repeated. Beware of calling flush too frequently: this will have a severe performance cost. Note that flush need not be called explicitly: it will be called automatically when the database is closed, or when a sufficient number of modifications have been made. =item add_document Add a new document to the database. This method adds the specified document to the database, returning a newly allocated document ID. Note that this does not mean the document will immediately appear in the database; see flush() for more details. As with all database modification operations, the effect is atomic: the document will either be fully added, or the document fails to be added and an exception is thrown (possibly at a later time when flush is called or the database is closed). =item delete_document Delete a document from the database. This method removes the document with the specified document ID from the database. Note that this does not mean the document will immediately disappear from the database; see flush() for more details. As with all database modification operations, the effect is atomic: the document will either be fully removed, or the document fails to be removed and an exception is thrown (possibly at a later time when flush is called or the database is closed). =item delete_document_by_term Delete any documents indexed by a term from the database. This method removes any documents indexed by the specified term from the database. The intended use is to allow UIDs from another system to easily be mapped to terms in Xapian, although this method probably has other uses. =item replace_document eplace a given document in the database. This method replaces the document with the specified document ID. Note that this does not mean the document will immediately change in the database; see flush() for more details. As with all database modification operations, the effect is atomic: the document will either be fully replaced, or the document fails to be replaced and an exception is thrown (possibly at a later time when flush is called or the database is closed). =item replace_document_by_term Replace any documents matching an unique term. This method replaces any documents indexed by the specified term with the specified document. If any documents are indexed by the term, the lowest document ID will be used for the document, otherwise a new document ID will be generated as for add_document. The intended use is to allow UIDs from another system to easily be mapped to terms in Xapian, although this method probably has other uses. Note that this does not mean the document(s) will immediately change in the database; see flush() for more details. As with all database modification operations, the effect is atomic: the document(s) will either be fully replaced, or the document(s) fail to be replaced and an exception is thrown (possibly at a later time when flush is called or the database is closed). =item add_spelling Add a word to the spelling dictionary. If the word is already present, its frequency is increased. Parameters: word The word to add. freqinc How much to increase its frequency by (default 1). =item remove_spelling Remove a word from the spelling dictionary. The word's frequency is decreased, and if would become zero or less then the word is removed completely. Parameters: word The word to remove. freqdec How much to decrease its frequency by (default 1). =item reopen Re-open the database to ensure you are using the latest revision. =item close Close the database. This also implies a commit() unless a transaction is in progress. =back =head1 SEE ALSO L, L, L =cut Search-Xapian-1.2.25.5/Xapian/MSetIterator.pm0000644000175000017500000000212413320553070017244 0ustar ollyollypackage Search::Xapian::MSetIterator; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '++' => sub { $_[0]->inc() }, '--' => sub { $_[0]->dec() }, '=' => sub { $_[0]->clone() }, 'eq' => sub { $_[0]->equal($_[1]) }, 'ne' => sub { $_[0]->nequal($_[1]) }, '==' => sub { $_[0]->equal($_[1]) }, '!=' => sub { $_[0]->nequal($_[1]) }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $iterator; my $invalid_args; if( scalar(@_) == 0 ) { $iterator = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $iterator = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$iterator)" ); exit; } bless $iterator, $class; return $iterator; } 1; Search-Xapian-1.2.25.5/Xapian/LogicError.pm0000644000175000017500000000135714207005157016743 0ustar ollyollypackage Search::Xapian::LogicError; =head1 NAME Search::Xapian::LogicError - The base class for exceptions indicating errors in the program logic. =head1 DESCRIPTION A subclass of LogicError will be thrown if Xapian detects a violation of a class invariant or a logical precondition or postcondition, etc. =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; use Search::Xapian::AssertionError; use Search::Xapian::InvalidArgumentError; use Search::Xapian::InvalidOperationError; use Search::Xapian::UnimplementedError; our @ISA = qw(DynaLoader Search::Xapian::Error); 1; Search-Xapian-1.2.25.5/Xapian/RSet.pm0000644000175000017500000000352113320553070015541 0ustar ollyollypackage Search::Xapian::RSet; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '=' => sub { $_[0]->clone() }, 'fallback' => 1; sub new() { my $class = shift; my $rset; my $invalid_args; if( scalar(@_) == 0 ) { $rset = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $rset = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$rset)" ); exit; } bless $rset, $class; return $rset; } sub add_document { my $self = shift; if( scalar(@_) == 1 ) { my $arg = shift; my $arg_class = ref( $arg ); if( $arg_class eq 'Search::Xapian::MSetIterator' ) { $self->add_document1($arg); } else { $self->add_document2($arg); } return; } Carp::carp( "USAGE: \$rset->add_document(\$docid) or \$rset->add_document(\$msetiterator)" ); exit; } sub remove_document { my $self = shift; if( scalar(@_) == 1 ) { my $arg = shift; my $arg_class = ref( $arg ); if( $arg_class eq 'Search::Xapian::MSetIterator' ) { $self->remove_document1($arg); } else { $self->remove_document2($arg); } return; } Carp::carp( "USAGE: \$rset->remove_document(\$docid) or \$rset->remove_document(\$msetiterator)" ); exit; } sub contains { my $self = shift; my $invalid_args; if( scalar(@_) == 1 ) { my $arg = shift; my $arg_class = ref( $arg ); if( $arg_class eq 'Search::Xapian::MSetIterator' ) { return $self->contains1($arg); } else { return $self->contains2($arg); } } Carp::carp( "USAGE: \$rset->contains(\$docid) or \$rset->contains(\$msetiterator)" ); exit; } 1; Search-Xapian-1.2.25.5/Xapian/InternalError.pm0000644000175000017500000000067514207005157017464 0ustar ollyollypackage Search::Xapian::InternalError; =head1 NAME Search::Xapian::InternalError - InternalError indicates a runtime problem of some sort. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/MSet.pm0000644000175000017500000000401013320553070015526 0ustar ollyollypackage Search::Xapian::MSet; use 5.006; use strict; use warnings; use Carp; use Search::Xapian::MSet::Tied; use Tie::Array; require DynaLoader; our @ISA = qw(Tie::Array DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '=' => sub { $_[0]->clone() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $mset; my $invalid_args; if( scalar(@_) == 0 ) { $mset = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $mset = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$mset)" ); exit; } bless $mset, $class; return $mset; } sub fetch() { my $self = shift; my $invalid_args; if( scalar(@_) == 2 ) { $self->fetch1(@_); } elsif( scalar(@_) == 1 ) { $self->fetch2(@_); } elsif( scalar(@_) == 0 ) { $self->fetch3(); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: \$mset->fetch(\$begin, \$end), \$mset->fetch(\$msetiterator), \$mset->fetch()" ); exit; } } sub convert_to_percent() { my $self = shift; my $invalid_args; if( scalar(@_) == 1 ) { my $arg = shift; my $arg_class = ref $arg; if( !$arg_class ) { return $self->convert_to_percent1($arg); } elsif( $arg_class eq 'Search::Xapian::MSetIterator' ) { return $self->convert_to_percent2($arg); } else { $invalid_args = 1; } } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: \$enquire->convert_to_percent(\$weight) or \$enquire->convert_to_percent(\$msetiterator)" ); exit; } } sub items { my $self = shift; my @array; tie( @array, 'Search::Xapian::MSet::Tied', $self ); return @array; } sub TIEARRAY { my $class = shift; my $eset = shift; return bless $eset, $class; } 1; Search-Xapian-1.2.25.5/Xapian/TradWeight.pm0000644000175000017500000000205013320553070016722 0ustar ollyollypackage Search::Xapian::TradWeight; use 5.006; use strict; use warnings; use Carp; use Search::Xapian::Weight; require DynaLoader; our @ISA = qw( DynaLoader Search::Xapian::Weight); # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub new { my $class = shift; my $weight; if (scalar(@_) == 0) { $weight = new1(); } elsif (scalar(@_) == 1) { $weight = new2(@_); } else { Carp::carp("USAGE: $class->new(), $class->new(k)"); exit; } bless $weight, $class; return $weight; } 1; __END__ =head1 NAME Search::Xapian::TradWeight - Traditional Probabilistic Weighting scheme. =head1 DESCRIPTION Traditional Probabilistic Weighting scheme, as described by the early papers on Probabilistic Retrieval. BM25 generally gives better results. =head1 METHODS =over 4 =item new Constructor. Either takes no parameters, or a single non-negative parameter k. If k isn't specified, the default value used is 1. =back =head1 SEE ALSO L, L =cut Search-Xapian-1.2.25.5/Xapian/MSet/0000755000175000017500000000000014207007026015175 5ustar ollyollySearch-Xapian-1.2.25.5/Xapian/MSet/Tied.pm0000644000175000017500000000021713320553070016420 0ustar ollyollypackage Search::Xapian::MSet::Tied; use 5.006; use strict; use warnings; use Search::Xapian::MSet; our @ISA = qw(Search::Xapian::MSet); 1; Search-Xapian-1.2.25.5/Xapian/UnimplementedError.pm0000644000175000017500000000072614207005157020513 0ustar ollyollypackage Search::Xapian::UnimplementedError; =head1 NAME Search::Xapian::UnimplementedError - UnimplementedError indicates an attempt to use an unimplemented feature. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::LogicError); 1; Search-Xapian-1.2.25.5/Xapian/QueryParserError.pm0000644000175000017500000000066514207005157020171 0ustar ollyollypackage Search::Xapian::QueryParserError; =head1 NAME Search::Xapian::QueryParserError - Indicates a query string can't be parsed. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/Stem.pm0000644000175000017500000000123013320553070015567 0ustar ollyollypackage Search::Xapian::Stem; use 5.006; use strict; use warnings; # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } 1; __END__ =head1 NAME Search::Xapian::Stem - Snowball stemmer =head1 SYNOPSIS my $stemmer = Search::Xapian::Stem->new('norwegian'); my $stemmed_foo = $stemmer->stem_word($foo); =head1 DESCRIPTION =head1 METHODS =over 4 =item new Constructor. Takes the language to stem as a parameter. =item stem_word Returns the stemmed form of the given word. =back =head1 SEE ALSO L, L, L =cut Search-Xapian-1.2.25.5/Xapian/NetworkError.pm0000644000175000017500000000074714207005157017341 0ustar ollyollypackage Search::Xapian::NetworkError; =head1 NAME Search::Xapian::NetworkError - Indicates a problem communicating with a remote database. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; use Search::Xapian::NetworkTimeoutError; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/DocNotFoundError.pm0000644000175000017500000000072214207005157020063 0ustar ollyollypackage Search::Xapian::DocNotFoundError; =head1 NAME Search::Xapian::DocNotFoundError - Indicates an attempt to access a document not present in the database. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/PositionIterator.pm0000644000175000017500000000544213320553070020206 0ustar ollyollypackage Search::Xapian::PositionIterator; use 5.006; use strict; use warnings; use Carp; use Scalar::Util 'blessed'; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '++' => sub { $_[0]->inc() }, '=' => sub { $_[0]->clone() }, 'eq' => sub { $_[0]->equal($_[1]) }, 'ne' => sub { $_[0]->nequal($_[1]) }, '==' => sub { $_[0]->equal($_[1]) }, '!=' => sub { $_[0]->nequal($_[1]) }, '""' => sub { $_[0]->get_description() }, '0+' => sub { $_[0]->get_termpos() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub equal() { my ($self, $other) = @_; if( blessed($other) && $other->isa('Search::Xapian::PositionIterator') ) { $self->equal1($other); } else { ($self+0) == ($other+0); } } sub nequal() { my ($self, $other) = @_; if( blessed($other) && $other->isa('Search::Xapian::PositionIterator') ) { $self->nequal1($other); } else { ($self+0) != ($other+0); } } sub new() { my $class = shift; my $iterator; my $invalid_args; if( scalar(@_) == 0 ) { $iterator = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $iterator = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$iterator)" ); exit; } bless $iterator, $class; return $iterator; } 1; __END__ =head1 NAME Search::Xapian::PositionIterator - Iterate over sets of positions. =head1 DESCRIPTION This iterator represents a stream of positions for a term. It overloads C<++> for advancing the iterator, or you can explicitly call the C method. This class also overloads C, C, C<==>, C, C<""> (stringification) and C<0+> (conversion to an integer). =head1 METHODS =over 4 =item new Constructor. Defaults to an uninitialized iterator. =item clone =item inc Advance the iterator by one. (Called implictly by C<++> overloading). =item skip_to Skip the iterator to term position termpos, or the first term position after termpos if termpos isn't in the list of term positions being iterated. =item equal Checks if a term is the same as this term. Also overloaded to the C and C<==> operators. =item nequal Checks if a term is different from this term. Also overloaded to the C and C operators. =item get_termpos Return the term position the iterator is currently on. Also implemented as conversion to an integer. =item get_description Return a description of this object. Also implemented as stringification. =back =head1 SEE ALSO L, L =cut Search-Xapian-1.2.25.5/Xapian/MultiValueSorter.pm0000644000175000017500000000230613320553070020152 0ustar ollyollypackage Search::Xapian::MultiValueSorter; use 5.006; use strict; use warnings; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub new() { my $class = shift; my $obj = new0(); bless $obj, $class; foreach (@_) { $obj->add($_) } return $obj; } 1; __END__ =head1 NAME Search::Xapian::MultiValueSorter - allows sorting by a several values. =head1 DESCRIPTION Results are ordered by the first value. In the event of a tie, the second is used. If this is the same for both, the third is used, and so on. =head1 SYNOPSIS use Search::Xapian; my $db = new Search::Xapian::Database("/path/to/db"); my $enq = new Search::Xapian::Enquire($db); my $sorter = new Search::Xapian::MultiValueSorter(1, 3, 5); $enq->set_sort_by_key($sorter); =head1 METHODS =over 4 =item new [...] Construct and add the values listed. =item add [] Add another value to sort on. By default, values sort forwards, unless forward is specified and is false. =back =head1 REFERENCE https://xapian.org/docs/sourcedoc/html/classXapian_1_1MultiValueSorter.html =cut Search-Xapian-1.2.25.5/Xapian/InvalidArgumentError.pm0000644000175000017500000000074014207005157020772 0ustar ollyollypackage Search::Xapian::InvalidArgumentError; =head1 NAME Search::Xapian::InvalidArgumentError - InvalidArgumentError indicates an invalid parameter value was passed to the API. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::LogicError); 1; Search-Xapian-1.2.25.5/Xapian/ValueCountMatchSpy.pm0000644000175000017500000000363113320553070020424 0ustar ollyollypackage Search::Xapian::ValueCountMatchSpy; use 5.006; use strict; use warnings; use Carp; use Search::Xapian::MatchSpy; require DynaLoader; our @ISA = qw( DynaLoader Search::Xapian::MatchSpy ); # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub new { my $class = shift; my $matcher; if (scalar(@_) == 0) { $matcher = new1(); } elsif (scalar(@_) == 1) { $matcher = new2(@_); } else { Carp::carp("USAGE: $class->new(), $class->new(slot)"); exit; } bless $matcher, $class; return $matcher; } 1; __END__ =head1 NAME Search::Xapian::ValueCountMatchSpy - Class for counting the frequencies of values in the matching documents. =head1 SYNOPSIS use Search::Xapian qw(:all); my $db = Search::Xapian::Database->new( '[DATABASE DIR]' ); my $enq = $db->enquire( '[QUERY TERM]' ); my $spy = Search::Xapian::ValueCountMatchSpy->new(0); $enq->add_matchspy($spy); my $mset = $enq->get_mset(0, 10, 10000); print "Match spy registered " . $spy->get_total() . " documents\n"; my $end = $spy->values_end(); for (my $it = $spy->values_begin(); $it != $end; $it++) { print $it->get_termname() . " - " . $it->get_termfreq(); } =head1 DESCRIPTION Class for counting the frequencies of values in the matching documents. Wraps Xapian::ValueCountMatchSpy =head1 METHODS =over 4 =item new Constructor. Either takes no parameters, or a single valueno parameter identifying the slot. =item get_total Return the total number of documents tallied. =item values_begin Get an iterator over the values seen in the slot. =item values_end End iterator corresponding to values_begin(). =item top_values_begin Get an iterator over the most frequent values seen in the slot. =item top_values_end End iterator corresponding to top_values_begin(). =back =head1 SEE ALSO L, L =cut Search-Xapian-1.2.25.5/Xapian/Weight.pm0000644000175000017500000000067113320553070016116 0ustar ollyollypackage Search::Xapian::Weight; use 5.006; use strict; use warnings; # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } 1; __END__ =head1 NAME Search::Xapian::Weight - base class for Weighting schemes. =head1 DESCRIPTION This is an abstract base class for weighting schemes in Xapian. =head1 SEE ALSO L, L, L =cut Search-Xapian-1.2.25.5/Xapian/TermGenerator.pm0000644000175000017500000000513413320553070017444 0ustar ollyollypackage Search::Xapian::TermGenerator; use 5.006; use strict; use warnings; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '=' => sub { $_[0]->clone() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $tg = new0(); bless $tg, $class; return $tg; } 1; __END__ =head1 NAME Search::Xapian::TermGenerator - Parses a piece of text and generates terms. =head1 DESCRIPTION This module takes a piece of text and parses it to produce words which are then used to generate suitable terms for indexing. The terms generated are suitable for use with L objects produced by the L class. =head1 SYNOPSIS use Search::Xapian; my $doc = new Search::Xapian::Document(); my $tg = new Search::Xapian::TermGenerator(); $tg->set_stemmer(new Search::Xapian::Stem("english")); $tg->set_document($doc); $tg->index_text("The cat sat on the mat"); =head1 METHODS =over 4 =item new TermGenerator constructor. =item set_stemmer Set the L object to be used for generating stemmed terms. =item set_stopper Set the L object to be used for identifying stopwords. =item set_document Set the L object to index terms into. =item get_document Get the currently set L object. =item index_text [ []] Indexes the text in string . The optional parameter sets the wdf increment (default 1). The optional parameter sets the term prefix to use (default is no prefix). =item index_text_without_positions [ []] Just like index_text, but no positional information is generated. This means that the database will be significantly smaller, but that phrase searching and NEAR won't be supported. =item increase_termpos [] Increase the termpos used by index_text by (default 100). This can be used to prevent phrase searches from spanning two unconnected blocks of text (e.g. the title and body text). =item get_termpos Get the current term position. =item set_termpos Set the current term position. =item get_description Return a description of this object. =back =head1 REFERENCE https://xapian.org/docs/sourcedoc/html/classXapian_1_1TermGenerator.html =cut Search-Xapian-1.2.25.5/Xapian/Error.pm0000644000175000017500000000211114207005157015752 0ustar ollyollypackage Search::Xapian::Error; =head1 NAME Search::Xapian::Error - Base class for all exceptions in Search::Xapian =head1 DESCRIPTION This is an abstract class in C++, i.e. it cannot be instantiated directly. In Perl there is no such concept, but you should not need to create instances of this class yourself. =head1 METHODS All exception objects have the following methods =head2 get_msg Returns a string with a descriptive error message, useful for outputting =head2 get_type The type of this error (e.g. "DocNotFoundError"). =head2 get_context Optional context information, returned as a string =head2 get_error_string Returns any error string from errno or similar associated with this error =cut use 5.006; use strict; use warnings; require DynaLoader; use Search::Xapian::LogicError; use Search::Xapian::RuntimeError; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub new { my $class = shift; my ($self); bless $self, $class; return $self; } 1; Search-Xapian-1.2.25.5/Xapian/AssertionError.pm0000644000175000017500000000127514207005157017654 0ustar ollyollypackage Search::Xapian::AssertionError; =head1 NAME Search::Xapian::AssertionError - AssertionError is thrown if a logical assertion inside Xapian fails. =head1 DESCRIPTION In a debug build of Xapian, a failed assertion in the core library code will cause AssertionError to be thrown. This represents a bug in Xapian (either an invariant, precondition, etc has been violated, or the assertion is incorrect!) =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::LogicError); 1; Search-Xapian-1.2.25.5/Xapian/SimpleStopper.pm0000644000175000017500000000103313320553070017466 0ustar ollyollypackage Search::Xapian::SimpleStopper; use 5.006; use strict; use warnings; use Search::Xapian::Stopper; require DynaLoader; our @ISA = qw(DynaLoader Search::Xapian::Stopper); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } #use overload '=' => sub { $_[0]->clone() }, # 'fallback' => 1; sub new { my $class = shift; my $stopper = new0(); bless $stopper, $class; foreach (@_) { $stopper->add($_); } return $stopper; } 1; Search-Xapian-1.2.25.5/Xapian/NetworkTimeoutError.pm0000644000175000017500000000073114207005157020701 0ustar ollyollypackage Search::Xapian::NetworkTimeoutError; =head1 NAME Search::Xapian::NetworkTimeoutError - Indicates a timeout expired while communicating with a remote database. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::NetworkError); 1; Search-Xapian-1.2.25.5/Xapian/Enquire.pm0000644000175000017500000001622713320553070016303 0ustar ollyollypackage Search::Xapian::Enquire; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub set_query { my $self = shift; my $query = shift; if( ref( $query ) ne 'Search::Xapian::Query' ) { $query = Search::Xapian::Query->new( $query, @_ ); $self->set_query1( $query ); return; } my $nargs = scalar(@_); if( $nargs > 1) { Carp::carp( "USAGE: \$enquire->set_query(\$query) or \$enquire->set_query(\$query, \$length)" ); exit; } if( $nargs == 0 ) { $self->set_query1( $query ); } else { $self->set_query2( $query, shift ); } } sub get_mset { my $self = shift; my $nargs = scalar(@_); if( $nargs == 3 ) { my $type = ref( $_[2] ); if ( $type eq 'CODE' ) { # get_mset(first, max, matchdecider) [perl extra] return $self->get_mset2(@_); } if ( $type eq 'Search::Xapian::RSet' ) { # get_mset(first, max, rset) splice @_, 2, 0, (0); # insert checkatleast } } elsif( $nargs == 4 && ref( $_[3] ) eq 'CODE' ) { # get_mset(first, max, rset, matchdecider) splice @_, 2, 0, (0); # insert checkatleast } return $self->get_mset1( @_ ); } sub matches { my $self = shift; return $self->get_mset(@_)->items(); } sub get_matching_terms_begin { my $self = shift; if( scalar(@_) == 1 ) { my $arg = shift; my $arg_class = ref( $arg ); if( $arg_class eq 'Search::Xapian::MSetIterator' ) { return $self->get_matching_terms_begin2($arg); } else { return $self->get_matching_terms_begin1($arg); } } Carp::carp( "USAGE: \$enquire->get_matching_terms_begin(\$docid) or \$enquire->get_matching_terms_begin(\$msetiterator)" ); exit; } sub get_matching_terms_end { my $self = shift; if( scalar(@_) == 1 ) { my $arg = shift; my $arg_class = ref( $arg ); if( $arg_class eq 'Search::Xapian::MSetIterator' ) { return $self->get_matching_terms_end2($arg); } else { return $self->get_matching_terms_end1($arg); } } Carp::carp( "USAGE: \$enquire->get_matching_terms_end(\$docid) or \$enquire->get_matching_terms_end(\$msetiterator)" ); exit; } 1; __END__ =head1 NAME Search::Xapian::Enquire - Make queries against a database =head1 DESCRIPTION This class provides an interface to the information retrieval system for the purpose of searching. =head1 METHODS =over 4 =item new =item set_query takes either a ready made L or a scalar containing a query, which in that case will be passed to L's constructor, together with any other passed arguments. =item set_query_object =item get_query =item matches [] Takes the start element, and maximum number of elements (and optionally the minimum number of matches to check), and returns an array tied to L. =item get_matching_terms_begin Returns a L, pointing to the start of the stream. =item get_matching_terms_end Returns a L, pointing to the end of the stream. =item set_collapse_key =item set_docid_order Set the direction in which documents are ordered by document id in the returned MSet. This order only has an effect on documents which would otherwise have equal rank. For a weighted probabilistic match with no sort value, this means documents with equal weight. For a boolean match, with no sort value, this means all documents. And if a sort value is used, this means documents with equal sort value (and also equal weight if ordering on relevance after the sort). order can be ENQ_ASCENDING (the default, docids sort in ascending order), ENQ_DESCENDING (docds sort in descending order), or ENQ_DONT_CARE (docids sort in whatever order is most efficient for the backend.) Note: If you add documents in strict date order, then a boolean search - i.e. set_weighting_scheme(Search::Xapian::BoolWeight->new()) - with set_docid_order(ENQ_DESCENDING) is a very efficient way to perform "sort by date, newest first". =item set_cutoff [] =item set_sort_by_relevance Set the sorting to be by relevance only. This is the default. =item set_sort_by_value [] Set the sorting to be by value only. sort_key - value number to reorder on. Sorting is with a string compare. If ascending is true (the default) higher is better; if ascending is false, lower is better. ascending - If true, document values which sort higher by string compare are better. If false, the sort order is reversed. (default true) =item set_sort_by_value_then_relevance [] Set the sorting to be by value, then by relevance for documents with the same value. sort_key - value number to reorder on. Sorting is with a string compare. If ascending is true (the default) higher is better; if ascending is false, lower is better. ascending - If true, document values which sort higher by string compare are better. If false, the sort order is reversed. (default true) =item set_sort_by_relevance_then_value [] Set the sorting to be by relevance then value. Note that with the default BM25 weighting scheme parameters, non-identical documents will rarely have the same weight, so this setting will give very similar results to set_sort_by_relevance(). It becomes more useful with particular BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom weighting schemes. sort_key - value number to reorder on. Sorting is with a string compare. If ascending is true (the default) higher is better; if ascending is false, lower is better. ascending - If true, document values which sort higher by string compare are better. If false, the sort order is reversed. (default true) =item set_sort_by_key [] Set the sorting to be by key only. sorter - the functor to use to build the key. ascending - If true, keys which sort higher by string compare are better. If false, the sort order is reversed. (default true) =item set_sort_by_key_then_relevance [] Set the sorting to be by key, then by relevance for documents with the same key. sorter - the functor to use to build the key. ascending - If true, keys which sort higher by string compare are better. If false, the sort order is reversed. (default true) =item set_sort_by_relevance_then_key [] Set the sorting to be by relevance then key. sorter - the functor to use to build the key. ascending - If true, keys which sort higher by string compare are better. If false, the sort order is reversed. (default true) =item get_mset Get match set. =item get_eset [] Get set of query expansion terms. =item get_description Return a description of this object. =item add_matchspy Add a matchspy. This matchspy will be called with some of the documents which match the query, during the match process. =item clear_matchspies Remove all the matchspies. =back =head1 SEE ALSO L, L, L =cut Search-Xapian-1.2.25.5/Xapian/Query.pm0000644000175000017500000000367013320553070015776 0ustar ollyollypackage Search::Xapian::Query; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '""' => sub { $_[0]->get_description() }, # FIXME: perhaps unwise? 'fallback' => 1; sub new { my $class = shift; my $query; if( @_ == 0 ) { $query = new0(); } elsif( @_ == 1 ) { $query = new1(@_); } else { my $op = $_[0]; if( $op !~ /^\d+$/ ) { Carp::croak( "USAGE: $class->new('term') or $class->new(OP, )" ); } if( $op == 8 ) { # FIXME: 8 is OP_VALUE_RANGE; eliminate hardcoded literal if( @_ != 4 ) { Carp::croak( "USAGE: $class->new(OP_VALUE_RANGE, VALNO, START, END)" ); } $query = new4range( @_ ); } elsif( $op == 9 ) { # FIXME: OP_SCALE_WEIGHT if( @_ != 3 ) { Carp::croak( "USAGE: $class->new(OP_SCALE_WEIGHT, QUERY, FACTOR)" ); } $query = new3scale( @_ ); } elsif( $op == 11 || $op == 12 ) { # FIXME: OP_VALUE_GE, OP_VALUE_LE; eliminate hardcoded literals if( @_ != 3 ) { Carp::croak( "USAGE: $class->new(OP_VALUE_[GL]E, VALNO, LIMIT)" ); } $query = new3range( @_ ); } else { $query = newN( @_ ); } } bless $query, $class; return $query; } sub new_term { my $class = shift; my $query; if (@_ < 1 or @_ > 3) { Carp::carp( "new_term takes 1, 2 or 3 arguments only" ); } my ($term, $wqf, $pos) = @_; $wqf = 1 unless defined $wqf; $pos = 0 unless defined $pos; $query = new1weight($term, $wqf, $pos); bless $query, $class; return $query; } sub get_terms { my $self = shift; my @terms; my $q=$self->get_terms_begin; while ($q ne $self->get_terms_end) { push @terms,$q->get_termname; $q++; } return @terms; } sub MatchNothing () { Search::Xapian::Query->new } sub MatchAll () { Search::Xapian::Query->new('') } 1; Search-Xapian-1.2.25.5/Xapian/ESetIterator.pm0000644000175000017500000000212413320553070017234 0ustar ollyollypackage Search::Xapian::ESetIterator; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '++' => sub { $_[0]->inc() }, '--' => sub { $_[0]->dec() }, '=' => sub { $_[0]->clone() }, 'eq' => sub { $_[0]->equal($_[1]) }, 'ne' => sub { $_[0]->nequal($_[1]) }, '==' => sub { $_[0]->equal($_[1]) }, '!=' => sub { $_[0]->nequal($_[1]) }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $iterator; my $invalid_args; if( scalar(@_) == 0 ) { $iterator = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $iterator = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$iterator)" ); exit; } bless $iterator, $class; return $iterator; } 1; Search-Xapian-1.2.25.5/Xapian/Database.pm0000644000175000017500000001054613320553070016375 0ustar ollyollypackage Search::Xapian::Database; use 5.006; use strict; use warnings; use Carp; use Search::Xapian::Enquire; require DynaLoader; our @ISA = qw(DynaLoader); # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } # Preloaded methods go here. use overload '=' => sub { $_[0]->clone() }, 'fallback' => 1; sub enquire { my $self = shift; my $enquire = Search::Xapian::Enquire->new( $self ); if( @_ ) { $enquire->set_query( @_ ); } return $enquire; } sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $database; my $invalid_args; if( scalar(@_) == 1 ) { my $arg = shift; my $arg_class = ref( $arg ); if( !$arg_class ) { $database = new1( $arg ); } elsif( $arg_class eq $class ) { $database = new2( $arg ); } else { $invalid_args = 1; } } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(\$file), $class->new(\$database)" ); exit; } bless $database, $class; return $database; } 1; __END__ =head1 NAME Search::Xapian::Database - Search database object =head1 DESCRIPTION This class represents a Xapian database for searching. See L for an object suitable for indexing. To perform searches, this class works with the L object. =head1 METHODS =over 4 =item new Class constructor. Can either take a path to an existing database or another database class as the first parameter =item clone Return a clone of this class. =item add_database Add an existing database (or group of databases) to those accessed by this object. =item reopen This re-opens the database(s) to the latest available version(s). It can be used either to make sure the latest results are returned, or to recover from a Xapian::DatabaseModifiedError. =item close Close the database. This also implies a commit() unless a transaction is in progress. =item enquire [] Returns a new L object. Any extra parameters are passed to set_query. =item get_doccount Returns the number of document indexed in this database. =item get_lastdocid Returns the id of the last used document. =item get_doclength Returns the length of a given document. =item get_document Returns a L object for the given document. =item get_avlength Get the average length of the documents in the database. =item get_termfreq Get the number of documents in the database indexed by a given term. =item term_exists returns true if this term exists in the database, or false otherwise. =item get_description return a description of this object. =item get_spelling_suggestion returns a suggested spelling correction. =item allterms_begin [] Returns a L iterating over the termlist for the the entire database. If the optional prefix argument is non-empty, only terms starting with that string are returned. =item allterms_end [] Returns a L pointing to the end of the termlist corresponding to allterms_begin. =item termlist_begin Returns a L pointing to the start of the termlist for a given document. =item termlist_end Returns a L pointing to the end of the termlist for a given document. =item positionlist_begin Returns a L pointing to the start of the position list for a given term in the given document. =item positionlist_end Returns a L pointing to the end of the position list for a given term in the given document. =item postlist_begin Returns a L pointing to the start of the posting list for a given term. =item postlist_end Returns a L pointing to the end of the posting list for a given term. =item keep_alive Send a "keep-alive" to remote databases to stop them timing out. =item get_collection_freq Get the number of elements indexed by a certain term. =back =head1 SEE ALSO L, L, L =cut Search-Xapian-1.2.25.5/Xapian/DatabaseCorruptError.pm0000644000175000017500000000072514207005157020767 0ustar ollyollypackage Search::Xapian::DatabaseCorruptError; =head1 NAME Search::Xapian::DatabaseCorruptError - DatabaseCorruptError indicates database corruption was detected. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::DatabaseError); 1; Search-Xapian-1.2.25.5/Xapian/DatabaseError.pm0000644000175000017500000000122214207005157017401 0ustar ollyollypackage Search::Xapian::DatabaseError; =head1 NAME Search::Xapian::DatabaseError - DatabaseError indicates some sort of database related error. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; use Search::Xapian::DatabaseCorruptError; use Search::Xapian::DatabaseCreateError; use Search::Xapian::DatabaseLockError; use Search::Xapian::DatabaseModifiedError; use Search::Xapian::DatabaseOpeningError; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/TermIterator.pm0000644000175000017500000000510613643245647017326 0ustar ollyollypackage Search::Xapian::TermIterator; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '++' => sub { $_[0]->inc() }, '=' => sub { $_[0]->clone() }, 'eq' => sub { $_[0]->equal($_[1]) }, 'ne' => sub { $_[0]->nequal($_[1]) }, '==' => sub { $_[0]->equal($_[1]) }, '!=' => sub { $_[0]->nequal($_[1]) }, '""' => sub { $_[0]->get_termname() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $iterator; my $invalid_args; if( scalar(@_) == 0 ) { $iterator = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $iterator = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$iterator)" ); exit; } bless $iterator, $class; return $iterator; } 1; __END__ =head1 NAME Search::Xapian::TermIterator - Iterate over sets of terms. =head1 DESCRIPTION This object represents a stream of terms. It overloads C<++> for advancing the iterator, or you can explicitly call the C method. This class also overloads C, C, C<==>, C, and C<""> (stringification). =head1 METHODS =over 4 =item new Constructor. Defaults to a uninitialized iterator. =item clone =item inc Advance the iterator by one. (Called implictly by C<++> overloading) =item skip_to Skip the iterator to term tname, or the first term after tname if tname isn't in the list of terms being iterated. =item get_termname Get the name of the current term. =item get_wdf Return the wdf of the current term (if meaningful). =item get_termfreq Return the term frequency of the current term (if meaningful). =item positionlist_begin Return L pointing to start of positionlist for current term. =item positionlist_end Return L pointing to end of positionlist for current term. =item get_description Returns a string describing this object. =item equal Checks if a termiterator is the same as this termiterator. Also overloaded as the C and C<==> operators. =item nequal Checks if a termiterator is different from this termiterator. Also overloaded as the C and C operators. =back =head1 SEE ALSO L, L =cut Search-Xapian-1.2.25.5/Xapian/DatabaseNotFoundError.pm0000644000175000017500000000072213756405004021065 0ustar ollyollypackage Search::Xapian::DatabaseNotFoundError; =head1 NAME Search::Xapian::DatabaseNotFoundError - Indicates an attempt to access a database not present. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::DatabaseOpeningError); 1; Search-Xapian-1.2.25.5/Xapian/DatabaseVersionError.pm0000644000175000017500000000202714207005157020753 0ustar ollyollypackage Search::Xapian::DatabaseVersionError; =head1 NAME Search::Xapian::DatabaseVersionError - DatabaseVersionError indicates that a database is in an unsupported format. =head1 DESCRIPTION From time to time, new versions of Xapian will require the database format to be changed, to allow new information to be stored or new optimisations to be performed. Backwards compatibility will sometimes be maintained, so that new versions of Xapian can open old databases, but in some cases Xapian will be unable to open a database because it is in too old (or new) a format. This can be resolved either be upgrading or downgrading the version of Xapian in use, or by rebuilding the database from scratch with the current version of Xapian. =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::DatabaseOpeningError); 1; Search-Xapian-1.2.25.5/Xapian/Stopper.pm0000644000175000017500000000106713754605456016344 0ustar ollyollypackage Search::Xapian::Stopper; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub new() { my $class = shift; my $stopper; my $invalid_args; if( scalar(@_) == 0 ) { $stopper = new1(); } else { $stopper = new2(@_); } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\@words)" ); exit; } bless $stopper, $class; return $stopper; } 1; Search-Xapian-1.2.25.5/Xapian/QueryParser.pm0000644000175000017500000001073313320553070017151 0ustar ollyollypackage Search::Xapian::QueryParser; use 5.006; use strict; use warnings; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '=' => sub { $_[0]->clone() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $qp = new0(); bless $qp, $class; $qp->set_database(@_) if scalar(@_) == 1; return $qp; } 1; __END__ =head1 NAME Search::Xapian::QueryParser - Parse a query string into a Search::Xapian::Query object =head1 DESCRIPTION This module turns a human readable string into something Xapian can understand. The syntax supported is designed to be similar to other web based search engines, so that users familiar with them don't have to learn a whole new syntax. =head1 SYNOPSIS use Search::Xapian qw/:standard/; my $qp = new Search::Xapian::QueryParser( [$database] ); $qp->set_stemmer(new Search::Xapian::Stem("english")); $qp->set_default_op(OP_AND); $database->enquire($qp->parse_query('a NEAR word OR "a phrase" NOT (too difficult) +eh')); =head1 METHODS =over 4 =item new QueryParser constructor. =item set_stemmer Set the Search::Xapian::Stem object to be used for stemming query terms. =item set_stemming_strategy Set the stemming strategy. Valid values are C, C, C. =item set_stopper Set the Search::Xapian::Stopper object to be used for identifying stopwords. =item set_default_op Set the default operator. This operator is used to combine non-filter query items when no explicit operator is used. The most useful values for this are OP_OR (the default) and OP_AND. OP_NEAR and OP_PHRASE can also be useful. See L for descriptions of these constants. =item get_default_op Returns the current default operator. =item set_database Pass a L object which is used to check whether terms exist in some situations. =item parse_query [] Parses the query string according to the rules defined in the query parser documentation below. You can specify certain flags to modify the searching behaviour: FLAG_BOOLEAN, FLAG_PHRASE, FLAG_LOVEHATE, FLAG_BOOLEAN_ANY_CASE, FLAG_WILDCARD, FLAG_PURE_NOT, FLAG_PARTIAL, FLAG_SPELLING_CORRECTION, FLAG_SYNONYM, FLAG_AUTO_SYNONYMS, FLAG_AUTO_MULTIWORD_SYNONYMS To specify multiple flags, "bitwise or" them together (with C<|>). The default flags are C =item add_prefix Add a probabilistic term prefix. E.g. $qp->add_prefix("author", "A"); Allows the user to search for author:orwell which will search for the term "Aorwel" (assuming English stemming is in use). Multiple fields can be mapped to the same prefix (so you can e.g. make title: and subject: aliases for each other). Parameters: field The user visible field name prefix The term prefix to map this to =item add_boolean_prefix prefix Add a boolean term prefix allowing the user to restrict a search with a boolean filter specified in the free text query. E.g. $p->add_boolean_prefix("site", "H"); Allows the user to restrict a search with site:xapian.org which will be converted to Hxapian.org combined with any probabilistic query with C. Multiple fields can be mapped to the same prefix (so you can e.g. make site: and domain: aliases for each other). Parameters: field The user visible field name prefix The term prefix to map this to =item stoplist_begin =item stoplist_end =item unstem_begin =item unstem_end =item get_description Returns a string describing this object. =item get_corrected_query_string Get the spelling-corrected query string. This will only be set if FLAG_SPELLING_CORRECTION is specified when QueryParser::parse_query() was last called. If there were no corrections, an empty string is returned. =item set_max_wildcard_expansion Specify the maximum expansion of a wildcard term. Note: you must also set FLAG_WILDCARD for wildcard expansion to happen. Parameter limit is the maximum number of terms each wildcard in the query can expand to, or 0 for no limit (which is the default). =cut =back =head1 REFERENCE https://xapian.org/docs/queryparser.html https://xapian.org/docs/sourcedoc/html/classXapian_1_1QueryParser.html =cut Search-Xapian-1.2.25.5/Xapian/PostingIterator.pm0000644000175000017500000000644713320553070020033 0ustar ollyollypackage Search::Xapian::PostingIterator; use 5.006; use strict; use warnings; use Carp; use Scalar::Util 'blessed'; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '++' => sub { $_[0]->inc() }, '=' => sub { $_[0]->clone() }, 'eq' => sub { $_[0]->equal($_[1]) }, 'ne' => sub { $_[0]->nequal($_[1]) }, '==' => sub { $_[0]->equal($_[1]) }, '!=' => sub { $_[0]->nequal($_[1]) }, '""' => sub { $_[0]->get_description() }, '0+' => sub { $_[0]->get_docid() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub equal() { my ($self, $other) = @_; if( blessed($other) && $other->isa('Search::Xapian::PostingIterator') ) { $self->equal1($other); } else { ($self+0) == ($other+0); } } sub nequal() { my ($self, $other) = @_; if( blessed($other) && $other->isa('Search::Xapian::PostingIterator') ) { $self->nequal1($other); } else { ($self+0) != ($other+0); } } sub new() { my $class = shift; my $iterator; my $invalid_args; if( scalar(@_) == 0 ) { $iterator = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $iterator = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$iterator)" ); exit; } bless $iterator, $class; return $iterator; } 1; __END__ =head1 NAME Search::Xapian::PostingIterator - Iterate over the list of documents indexed by a term. =head1 DESCRIPTION This iterator represents a stream of documents indexed by a term. It overloads C<++> for advancing the iterator, or you can explicitly call the C method. This class also overloads C, C, C<==>, C, and C<""> (stringification). =head1 METHODS =over 4 =item new Constructor. Defaults to an uninitialized iterator. =item clone =item inc Advance the iterator by one. (Called implictly by C<++> overloading). =item skip_to Skip the iterator to term tname, or the first term after tname if tname isn't in the list of terms being iterated. =item get_docid Get the unique id of this document. =item get_wdf Return the wdf of the current term (if meaningful). =item positionlist_begin Return L pointing to start of positionlist for current term. =item positionlist_end Return L pointing to end of positionlist for current term. =item get_doclength Get the length of the document at the current position in the postlist. This information may be stored in the postlist, in which case this lookup should be extremely fast (indeed, not require further disk access). If the information is not present in the postlist, it will be retrieved from the database, at a greater performance cost. =item equal Checks if a term is the same as this term. Also overloaded to the C and C<==> operators. =item nequal Checks if a term is different from this term. Also overloaded to the C and C operators. =item get_description Return a description of this object. =back =head1 SEE ALSO L, L =cut Search-Xapian-1.2.25.5/Xapian/DatabaseLockError.pm0000644000175000017500000000070614207005157020220 0ustar ollyollypackage Search::Xapian::DatabaseLockError; =head1 NAME Search::Xapian::DatabaseLockError - DatabaseLockError indicates failure to lock a database. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::DatabaseError); 1; Search-Xapian-1.2.25.5/Xapian/WildcardError.pm0000644000175000017500000000070214207005157017430 0ustar ollyollypackage Search::Xapian::WildcardError; =head1 NAME Search::Xapian::WildcardError - WildcardError indicates an error expanding a wildcarded query. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/RangeError.pm0000644000175000017500000000071214207005157016734 0ustar ollyollypackage Search::Xapian::RangeError; =head1 NAME Search::Xapian::RangeError - RangeError indicates an attempt to access outside the bounds of a container. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/ValueIterator.pm0000644000175000017500000000433313641224001017447 0ustar ollyollypackage Search::Xapian::ValueIterator; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '++' => sub { $_[0]->inc() }, '=' => sub { $_[0]->clone() }, 'eq' => sub { $_[0]->equal($_[1]) }, 'ne' => sub { $_[0]->nequal($_[1]) }, '==' => sub { $_[0]->equal($_[1]) }, '!=' => sub { $_[0]->nequal($_[1]) }, '""' => sub { $_[0]->get_value() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $iterator; my $invalid_args; if( scalar(@_) == 0 ) { $iterator = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $iterator = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$iterator)" ); exit; } bless $iterator, $class; return $iterator; } 1; __END__ =head1 NAME Search::Xapian::ValueIterator - Iterate over value slots in a document. =head1 DESCRIPTION This object represents a stream of document values. It overloads C<++> for advancing the iterator, or you can explicitly call the C method. This class also overloads C, C, C<==>, C, and C<""> (stringification). =head1 METHODS =over 4 =item new Constructor. Defaults to a uninitialized iterator. =item clone =item inc Advance the iterator by one. (Called implictly by C<++> overloading ) =item get_valueno Return the number of the value slot at the current position. =item get_value Return the string in the value slot at current position. Also overloaded as the C<""> operator. =item get_description Returns a string describing this object. =item equal Checks if a valueiterator is the same as this valueiterator. Also overloaded as the C and C operators. =item nequal Checks if a valueiterator is different from this valueiterator. Also overloaded as the C and C operators. =back =head1 SEE ALSO L, L =cut Search-Xapian-1.2.25.5/Xapian/DatabaseCreateError.pm0000644000175000017500000000072014207005157020527 0ustar ollyollypackage Search::Xapian::DatabaseCreateError; =head1 NAME Search::Xapian::DatabaseCreateError - DatabaseCreateError indicates a failure to create a database. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::DatabaseError); 1; Search-Xapian-1.2.25.5/Xapian/BoolWeight.pm0000644000175000017500000000143313320553070016727 0ustar ollyollypackage Search::Xapian::BoolWeight; use 5.006; use strict; use warnings; use Carp; use Search::Xapian::Weight; require DynaLoader; our @ISA = qw( DynaLoader Search::Xapian::Weight); # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub new { my $class = shift; my $weight; if (scalar(@_) == 0) { $weight = new1(); } else { Carp::carp("USAGE: $class->new()"); exit; } bless $weight, $class; return $weight; } 1; __END__ =head1 NAME Search::Xapian::BoolWeight - Boolean Weighting scheme. =head1 DESCRIPTION Boolean Weighting scheme. All documents get a weight of 0. =head1 METHODS =over 4 =item new Constructor. Takes no arguments. =back =head1 SEE ALSO L, L =cut Search-Xapian-1.2.25.5/Xapian/DatabaseModifiedError.pm0000644000175000017500000000113514207005157021045 0ustar ollyollypackage Search::Xapian::DatabaseModifiedError; =head1 NAME Search::Xapian::DatabaseModifiedError - DatabaseModifiedError indicates a database was modified. =head1 DESCRIPTION To recover after catching this error, you need to call Xapian::Database::reopen() on the Database and repeat the operation which failed. =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::DatabaseError); 1; Search-Xapian-1.2.25.5/Xapian/BM25Weight.pm0000644000175000017500000000172613320553070016506 0ustar ollyollypackage Search::Xapian::BM25Weight; use 5.006; use strict; use warnings; use Carp; use Search::Xapian::Weight; require DynaLoader; our @ISA = qw( DynaLoader Search::Xapian::Weight); # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub new { my $class = shift; my $weight; if (scalar(@_) == 0) { $weight = new1(); } elsif (scalar(@_) == 5) { $weight = new2(@_); } else { Carp::carp("USAGE: $class->new(), $class->new(k1, k2, k3, b, min_normlen)"); exit; } bless $weight, $class; return $weight; } 1; __END__ =head1 NAME Search::Xapian::BM25Weight - BM25 Weighting scheme. =head1 DESCRIPTION BM25 Weighting scheme. This is the default weighting scheme. =head1 METHODS =over 4 =item new Constructor. Either takes no parameters, or the 4 BM25 parameters (k1, k2, k3, b) and the minimum normalised document length. =back =head1 SEE ALSO L, L =cut Search-Xapian-1.2.25.5/Xapian/DatabaseClosedError.pm0000644000175000017500000000070213756405004020540 0ustar ollyollypackage Search::Xapian::DatabaseClosedError; =head1 NAME Search::Xapian::DatabaseClosedError - Indicates an attempt to access a closed database. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::DatabaseError); 1; Search-Xapian-1.2.25.5/Xapian/DatabaseOpeningError.pm0000644000175000017500000000077214207005157020732 0ustar ollyollypackage Search::Xapian::DatabaseOpeningError; =head1 NAME Search::Xapian::DatabaseOpeningError - DatabaseOpeningError indicates failure to open a database. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; use Search::Xapian::DatabaseVersionError; our @ISA = qw(DynaLoader Search::Xapian::DatabaseError); 1; Search-Xapian-1.2.25.5/Xapian/PerlStopper.pm0000644000175000017500000000041713320553070017144 0ustar ollyollypackage Search::Xapian::PerlStopper; use 5.006; use strict; use warnings; use Search::Xapian::Stopper; @Search::Xapian::PerlStopper::ISA = qw(Search::Xapian::Stopper); # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } 1; Search-Xapian-1.2.25.5/Xapian/Document.pm0000644000175000017500000000530313320553070016442 0ustar ollyollypackage Search::Xapian::Document; use 5.006; use strict; use warnings; use Carp; require DynaLoader; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '=' => sub { $_[0]->clone() }, 'fallback' => 1; sub clone() { my $self = shift; my $class = ref( $self ); my $copy = new2( $self ); bless $copy, $class; return $copy; } sub new() { my $class = shift; my $document; my $invalid_args; if( scalar(@_) == 0 ) { $document = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $document = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$document)" ); exit; } bless $document, $class; return $document; } 1; __END__ =head1 NAME Search::Xapian::Document - Document object =head1 DESCRIPTION This class represents a document in a Xapian database. =head1 METHODS =over 4 =item new Class constructor. =item clone Return a clone of this class. =item get_value (value_no) Returns the value by the assigned number. =item add_value Set a value by value number. =item remove_value Removes the value with the assigned number. =item clear_values Clear all set values. =item get_data Return all document data. =item set_data Set all document data. This can be anything you like. =item add_posting [] Adds a term at the given position. wdfinc defaults to 1. =item remove_posting [] Removes a term from the given position. wdfdec defaults to 1. =item add_term [] Adds a term without positional information. wdfinc defaults to 1. =item add_boolean_term Adds a term intended for boolean filtering (its wdf contribution will be 0). =item remove_term Removes a term and all postings associated with it. =item clear_terms Remove all terms from the document. =item termlist_count Returns number of different terms in the document. =item termlist_begin Iterator for the terms in this document. Returns a L. =item termlist_end Equivalent end iterator for termlist_begin(). Returns a L. =item values_count Return number of defined values for this document. =item values_begin Return a L pointing at the start of the values in this document. =item values_end Return a L pointing at the end of the values in this document. =item get_description Return a description of this object. =back =head1 SEE ALSO L =cut Search-Xapian-1.2.25.5/Xapian/RuntimeError.pm0000644000175000017500000000177414207005157017334 0ustar ollyollypackage Search::Xapian::RuntimeError; =head1 NAME Search::Xapian::RuntimeError - The base class for exceptions indicating errors only detectable at runtime. =head1 DESCRIPTION A subclass of RuntimeError will be thrown if Xapian detects an error which is exception derived from RuntimeError is thrown when an error is caused by problems with the data or environment rather than a programming mistake. =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; use Search::Xapian::DatabaseError; use Search::Xapian::DocNotFoundError; use Search::Xapian::FeatureUnavailableError; use Search::Xapian::InternalError; use Search::Xapian::NetworkError; use Search::Xapian::QueryParserError; use Search::Xapian::SerialisationError; use Search::Xapian::RangeError; use Search::Xapian::WildcardError; our @ISA = qw(DynaLoader Search::Xapian::Error); 1; Search-Xapian-1.2.25.5/Xapian/ESet.pm0000644000175000017500000000163713320553070015532 0ustar ollyollypackage Search::Xapian::ESet; use 5.006; use strict; use warnings; use Carp; use Tie::Array; require DynaLoader; our @ISA = qw(Tie::Array DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } use overload '=' => sub { $_[0]->clone() }, 'fallback' => 1; sub new() { my $class = shift; my $mset; my $invalid_args; if( scalar(@_) == 0 ) { $mset = new1(); } elsif( scalar(@_) == 1 and ref( $_[1] ) eq $class ) { $mset = new2(@_); } else { $invalid_args = 1; } if( $invalid_args ) { Carp::carp( "USAGE: $class->new(), $class->new(\$eset)" ); exit; } bless $mset, $class; return $mset; } sub items { my $self = shift; my @array; tie( @array, 'Search::Xapian::ESet', $self ); return @array; } sub TIEARRAY { my $class = shift; my $eset = shift; return bless $eset, $class; } 1; Search-Xapian-1.2.25.5/Xapian/FeatureUnavailableError.pm0000644000175000017500000000114614207005157021441 0ustar ollyollypackage Search::Xapian::FeatureUnavailableError; =head1 NAME Search::Xapian::FeatureUnavailableError - Indicates an attempt to use a feature which is unavailable. =head1 DESCRIPTION Typically a feature is unavailable because it wasn't compiled in, or because it requires other software or facilities which aren't available. =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::RuntimeError); 1; Search-Xapian-1.2.25.5/Xapian/InvalidOperationError.pm0000644000175000017500000000072514207005157021153 0ustar ollyollypackage Search::Xapian::InvalidOperationError; =head1 NAME Search::Xapian::InvalidOperationError - InvalidOperationError indicates the API was used in an invalid way. =head1 DESCRIPTION =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".$_[0]->get_msg }; our @ISA = qw(DynaLoader Search::Xapian::LogicError); 1; Search-Xapian-1.2.25.5/makehtmldocs0000755000175000017500000000460713320553070015515 0ustar ollyolly#!/usr/bin/perl -W use strict; -d "html" and system("rm -rf html"); mkdir "html", 0777 or die $!; mkdir "html/Search", 0777 or die $!; my %pages = (); pod2html('Xapian.pm', 'html/Search/Xapian.html'); mkdir "html/Search/Xapian", 0777 or die $!; for my $f () { my $o = $f; $o =~ s/\.pm$/.html/; pod2html($f, "html/Search/$o"); } for (sort keys %pages) { my $v = $pages{$_}; if ($v eq 'Y') { print "$_ has a POD but is never linked to\n"; } elsif ($v =~ /^N=/) { print "$_ has no POD but is linked to\n"; } elsif ($v eq 'N') { # print "$_ has no POD (but no links)\n"; } } sub pod2html { my ($in, $out) = @_; my $tmp = 'pod2html.tmp'; my $root = '.'; $root = 'Xapian' if $out =~ m!/Xapian\.html$!; my $is_pod; open POD, $in or die $!; while () { if (/^=/) { $is_pod = 1; last; } } close POD; my $class = $in; $class =~ s!\.pm$!!; $class =~ s!/!::!g; $class = "Search::$class"; open HTML, ">$out" or die $!; if (!$is_pod) { $pages{$class} = 'N' . ($pages{$class} || ''); print HTML < $class

No Perl-specific documentation currently exists for class $class - please refer to the C++ API documentation for now. EOT } else { $pages{$class} = 'Y' . ($pages{$class} || ''); system('pod2html', '--podroot=blib/lib', '--podpath=.', '--htmlroot', $root, '--infile', $in, '--outfile', $tmp) == 0 or die $!; if ($?) { die $?; } open TMP, $tmp or die $!; while () { s!>the (.*?) manpage$1new(shift @ARGV); while (scalar @ARGV && $ARGV[0] ne '--') { # Xapian can transparently search several databases together. my $extra_db = Search::Xapian::Database->new(shift @ARGV); $database->add_database($extra_db); } shift @ARGV; # Default is sort by relevance. my $sort_by; if (scalar @ARGV && $ARGV[0] =~ /^-s(\w+)$/) { if ($1 eq 'date') { $sort_by = 0; } elsif ($1 eq 'id') { $sort_by = 1; } elsif ($1 eq 'type') { $sort_by = 2; } elsif ($1 eq 'author') { $sort_by = 3; } elsif ($1 eq 'title') { $sort_by = 4; } else { print STDERR "Bad option '-s$1'.\n"; exit 1; } shift @ARGV; } # Start an enquire session. my $enquire = Search::Xapian::Enquire->new($database); # Combine the remaining command line arguments with a space between each. # This means that simple queries without shell metacharacters in don't # have to be quoted just to appear as a single argument to the shell. my $query_string = join ' ', @ARGV; # Set up the QueryParser how we want. my $qp = Search::Xapian::QueryParser->new(); $qp->set_database($database); $qp->set_stemmer(Search::Xapian::Stem->new("english")); $qp->set_stemming_strategy(STEM_SOME); # Prefixes for free-text fields. $qp->add_prefix('title', 'S'); $qp->add_prefix('author', 'A'); # Prefixes for boolean filters. $qp->add_boolean_prefix('type', 'XTYPE'); $qp->add_boolean_prefix('id', 'Q'); # Second argument of 1 means "prefer mm/dd/yyyy". # Third argument means that two digit years < 20 are 20xx; >= 29 are 19xx. my $vrpdate = new Search::Xapian::DateValueRangeProcessor($SLOT_DATE, 1, 1920); $qp->add_valuerangeprocessor($vrpdate); # Parse the query string and return a Xapian::Query object. my $query = $qp->parse_query( $query_string, FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE|FLAG_WILDCARD ); print "Internal view of parsed query is:\n$query\n\n"; $enquire->set_query($query); if (defined $sort_by) { $enquire->set_sort_by_value($sort_by, 0); } # Return the top 10 results for the query. my $mset = $enquire->get_mset(0, 10); my $msize = $mset->size(); if ($msize == 0) { print "No matching documents found.\n"; exit 0; } # Display the results. if ($mset->get_matches_lower_bound() != $mset->get_matches_upper_bound()) { print "About "; } printf "%u matching documents were found.\n", $mset->get_matches_estimated(); print "Results 1-$msize:\n"; foreach my $m ($mset->items()) { printf "#%u: Score %u%%: %s\n", $m->get_rank() + 1, $m->get_percent(), $m->get_document()->get_data(); } }; if ($@) { # Report the exception which we've caught. print STDERR "Exception: $@\n"; exit 1; } Search-Xapian-1.2.25.5/examples/simpleindex.pl0000755000175000017500000000356313320553070017613 0ustar ollyolly#!/usr/bin/perl # # Index each paragraph of a text file as a Xapian document. # # Copyright (C) 2003 James Aylett # Copyright (C) 2004,2007,2009 Olly Betts # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA use 5.006; use strict; use warnings; use Search::Xapian (':all'); if (scalar @ARGV != 1) { print STDERR "Usage: $0 PATH_TO_DATABASE\n"; exit(1); } eval { # Open the database for update, creating a new database if necessary. my $database = Search::Xapian::WritableDatabase->new($ARGV[0], DB_CREATE_OR_OPEN); my $indexer = Search::Xapian::TermGenerator->new(); my $stemmer = Search::Xapian::Stem->new("english"); $indexer->set_stemmer($stemmer); my $para = ''; while (my $line = ) { $line =~ s/\s+$//; $line =~ s/^\s+//; if ($line eq '') { if ($para ne '') { # We've reached the end of a paragraph, so index it. my $doc = Search::Xapian::Document->new(); $doc->set_data($para); $indexer->set_document($doc); $indexer->index_text($para); # Add the document to the database. $database->add_document($doc); $para = ''; } } else { if ($para ne '') { $para .= ' '; } $para .= $line; } } }; if ($@) { print STDERR "Exception: $@\n"; exit(1); } Search-Xapian-1.2.25.5/examples/simpleexpand.pl0000755000175000017500000000623213320553070017757 0ustar ollyolly#!/usr/bin/perl # # Simple example script demonstrating query expansion. # # Copyright (C) 2003 James Aylett # Copyright (C) 2004,2006,2007,2009 Olly Betts # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA use 5.006; use strict; use warnings; use Search::Xapian (':all'); # We require at least two command line arguments. if (scalar @ARGV < 2) { print STDERR "Usage: $0 PATH_TO_DATABASE QUERY [-- [DOCID...]]\n"; exit(1); } eval { # Open the database for searching. my $database = Search::Xapian::Database->new(shift @ARGV); # Start an enquire session. my $enquire = Search::Xapian::Enquire->new($database); # Combine command line arguments up to "--" with spaces between # them, so that simple queries don't have to be quoted at the shell # level. my $sep_index = 0; while (exists $ARGV[$sep_index] && $ARGV[$sep_index] ne '--') { $sep_index++; } my $query_string = join ' ', @ARGV[0 .. $sep_index - 1]; # Create an RSet with the listed docids in. my $reldocs = Search::Xapian::RSet->new(); foreach my $did (@ARGV[$sep_index + 1 .. $#ARGV]) { $reldocs->add_document($did); } # Parse the query string to produce a Xapian::Query object. my $qp = Search::Xapian::QueryParser->new(); my $stemmer = Search::Xapian::Stem->new("english"); $qp->set_stemmer($stemmer); $qp->set_database($database); $qp->set_stemming_strategy(STEM_SOME); my $query = $qp->parse_query($query_string); my $mset; if (!$query->empty()) { print "Parsed query is: $query\n"; # Find the top 10 results for the query. $enquire->set_query($query); $mset = $enquire->get_mset(0, 10, $reldocs); # Display the results. printf "%i results found.\n", $mset->get_matches_estimated(); printf "Results 1-%i:\n", $mset->size(); foreach my $m ($mset->items()) { printf "%i: %i%% docid=%i [%s]\n", $m->get_rank() + 1, $m->get_percent(), $m->get_docid(), $m->get_document()->get_data(); } } # Put the top 5 (at most) docs into the rset if rset is empty if ($reldocs->empty() && defined $mset) { my $last = $mset->size() - 1; if ($last > 4) { $last = 4; } foreach my $m (($mset->items())[0..$last]) { $reldocs->add_document($m->get_docid()); } } # Get the suggested expand terms my $eset = $enquire->get_eset(10, $reldocs); printf "%i suggested additional terms\n", $eset->size(); for my $k ($eset->items()) { printf "%s: %f\n", $k->get_termname(), $k->get_weight(); } }; if ($@) { print STDERR "Exception: $@\n"; exit(1); } Search-Xapian-1.2.25.5/examples/simplematchdecider.pl0000755000175000017500000000516713320553070021122 0ustar ollyolly#!/usr/bin/perl # # Simple command-line match decider example # # Copyright (C) 2003 James Aylett # Copyright (C) 2004,2007,2009 Olly Betts # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA use 5.006; use strict; use warnings; use Search::Xapian (':all'); # This example runs a query like simplesearch does, but uses a MatchDecider # (mymatchdecider) to discard any document for which value 0 is equal to # the string passed as the second command line argument. # We require at least three command line arguments. if (scalar @ARGV < 3) { print STDERR "Usage: $0 PATH_TO_DATABASE AVOID_VALUE QUERY\n"; exit(1); } my $avoid_value; sub mymatchdecider { return $_[0]->get_value(0) ne $avoid_value; } eval { # Open the database for searching. my $database = Search::Xapian::Database->new(shift @ARGV); # Start an enquire session. my $enquire = Search::Xapian::Enquire->new($database); $avoid_value = shift @ARGV; # Combine the rest of the command line arguments with spaces between # them, so that simple queries don't have to be quoted at the shell # level. my $query_string = join ' ', @ARGV; # Parse the query string to produce a Xapian::Query object. my $qp = Search::Xapian::QueryParser->new(); my $stemmer = Search::Xapian::Stem->new("english"); $qp->set_stemmer($stemmer); $qp->set_database($database); $qp->set_stemming_strategy(STEM_SOME); my $query = $qp->parse_query($query_string); print "Parsed query is: $query\n"; # Find the top 10 results for the query. $enquire->set_query($query); my $mset = $enquire->get_mset(0, 10, \&mymatchdecider); # Display the results. printf "%i results found.\n", $mset->get_matches_estimated(); printf "Results 1-%i:\n", $mset->size(); foreach my $m ($mset->items()) { printf "%i: %i%% docid=%i [%s]\n", $m->get_rank() + 1, $m->get_percent(), $m->get_docid(), $m->get_document()->get_data(); } }; if ($@) { print STDERR "Exception: $@\n"; exit(1); } Search-Xapian-1.2.25.5/examples/simplesearch.pl0000755000175000017500000000440613320553070017746 0ustar ollyolly#!/usr/bin/perl # # Simple command-line search script. # # Copyright (C) 2003 James Aylett # Copyright (C) 2004,2007,2009 Olly Betts # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA use 5.006; use strict; use warnings; use Search::Xapian (':all'); # We require at least two command line arguments. if (scalar @ARGV < 2) { print STDERR "Usage: $0 PATH_TO_DATABASE QUERY\n"; exit(1); } eval { # Open the database for searching. my $database = Search::Xapian::Database->new(shift @ARGV); # Start an enquire session. my $enquire = Search::Xapian::Enquire->new($database); # Combine the rest of the command line arguments with spaces between # them, so that simple queries don't have to be quoted at the shell # level. my $query_string = join ' ', @ARGV; # Parse the query string to produce a Xapian::Query object. my $qp = Search::Xapian::QueryParser->new(); my $stemmer = Search::Xapian::Stem->new("english"); $qp->set_stemmer($stemmer); $qp->set_database($database); $qp->set_stemming_strategy(STEM_SOME); my $query = $qp->parse_query($query_string); print "Parsed query is: $query\n"; # Find the top 10 results for the query. $enquire->set_query($query); my $mset = $enquire->get_mset(0, 10); # Display the results. printf "%i results found.\n", $mset->get_matches_estimated(); printf "Results 1-%i:\n", $mset->size(); foreach my $m ($mset->items()) { printf "%i: %i%% docid=%i [%s]\n", $m->get_rank() + 1, $m->get_percent(), $m->get_docid(), $m->get_document()->get_data(); } }; if ($@) { print STDERR "Exception: $@\n"; exit(1); } Search-Xapian-1.2.25.5/examples/full-indexer.pl0000755000175000017500000000757013320553070017672 0ustar ollyolly#!/usr/bin/perl # # A sample indexer which demonstrates many of Xapian's commonly used features. # # Copyright (C) 2009 Olly Betts # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use 5.006; use strict; use warnings; use Search::Xapian (':all'); use POSIX; # Constants denoting what we're using the number value slots for. my $SLOT_DATE = 0; my $SLOT_DOCNUM = 1; my $SLOT_TYPE = 2; my $SLOT_AUTHOR = 3; my $SLOT_TITLE = 4; # We want exactly one command line argument. if (scalar @ARGV != 1) { print STDERR "Usage: $0 PATH_TO_DATABASE\n"; exit 1; } my ($database, $indexer); eval { # Open the database for writing. If it doesn't exist, create it. $database = Search::Xapian::WritableDatabase->new( $ARGV[0], DB_CREATE_OR_OPEN); # Set up a TermGenerator to index text stemmed with the "english" stemmer. $indexer = Search::Xapian::TermGenerator->new(); my $stemmer = Search::Xapian::Stem->new("english"); $indexer->set_stemmer($stemmer); }; if ($@) { # Report the exception which we've caught. print STDERR "Exception: $@\n"; exit 1; } # Add some documents to the index (in a real indexer, this data would come from # some external source like a file or a database). index_document( "The Old Man and the Sea", "Ernest Hemingway", "Santiago goes fishing, without much success.", "978-0-684-80122-3", "1952-09-01", "book" ); index_document( "Star Wars", "George Lucas", "Luke goes to meet his destiny in the stars.", "tt0076759", "1977-05-25", "film" ); index_document( "Accidental Death of an Anarchist", "Dario Fo", "An anarchist dies, accidentally!", "12345", "1970-12-10", "play" ); sub index_document { my ($doc_name, $author, $keywords, $doc_number, $date, $type) = @_; eval { my $doc = Search::Xapian::Document->new(); $indexer->set_document($doc); # Set the document data to the doc_name so we can show it for matches. $doc->set_data($doc_name); # Index the author to allow fielded free-text searching. $indexer->index_text($author, 1, "A"); # Index the title to allow fielded free-text searching. $indexer->index_text($doc_name, 1, "S"); # Index the title without a prefix too. $indexer->index_text($doc_name); # Increase the term position so that phrases can't straddle the # doc_name and keywords. $indexer->increase_termpos(); # Index the keywords as free-text. $indexer->index_text($keywords); # Unique ID. $doc->add_term("Q" . $doc_number); # To allow boolean filtering by type. $doc->add_term("XTYPE" . lc $type); # To allow date range searching and sorting by date. if ($date =~ /^(\d{4})-(\d\d)-(\d\d)$/) { # DateValueRangeProcessor wants values in the form "YYYYMMDD". $doc->add_value($SLOT_DATE, "$1$2$3"); } # To allow sorting by document number. $doc->add_value($SLOT_DOCNUM, $doc_number); # To allow sorting by document type. $doc->add_value($SLOT_TYPE, lc $type); # To allow sorting by author. $doc->add_value($SLOT_AUTHOR, $author); # To allow sorting by title.. $doc->add_value($SLOT_TITLE, $doc_name); # Add the document to the database. $database->add_document($doc); }; if ($@) { # Report the exception which we've caught. print STDERR "Exception: $@\n"; exit 1; } } Search-Xapian-1.2.25.5/generate-perl-exceptions0000644000175000017500000001177613756405261017770 0ustar ollyolly#!/usr/bin/perl -w use strict; # Author: Andreas Marienborg # Donated as is to xapian project. Use and modify as see fit BEGIN { my $dir = shift || '.'; if ($dir eq '--help') { print "Syntax: $0 [ []\n\n"; print "This script needs to know the source directory to find\n"; print "exception_data.pm - by default it looks in '.'.\n"; exit 0; } push(@INC, $dir); $::version = shift || ''; if ($::version =~ /^(\d+)\.(\d+)\,(\d+)/) { $::version = $1 * 1000000 + $2 * 1000 + $3; } else { # Assume 1.4.x if not specified. $::version = 1004000; } } # We load the exception data from xapian-core. use exception_data qw(@baseclasses @classes %subclasses); # Generate typemaps for Xapian::Error and its subclasses. my $tm = "typemap-errorclasses"; open(TM, ">", "$tm.tmp") or die "cannot write '$tm.tmp': $!\n"; foreach (@baseclasses, @classes) { my ($classname, $parent, $desc) = split /\t/; print TM "$classname\tO_OBJECT\n"; print TM "$classname *\tO_OBJECT\n"; } close TM; rename "$tm.tmp", $tm or die "Failed to rename '$tm.tmp' to '$tm': $!\n"; my $fnm = "Xapian/Error.pm"; open F, '>', "$fnm.tmp" or die $!; print F <<'END'; package Search::Xapian::Error; =head1 NAME Search::Xapian::Error - Base class for all exceptions in Search::Xapian =head1 DESCRIPTION This is an abstract class in C++, i.e. it cannot be instantiated directly. In Perl there is no such concept, but you should not need to create instances of this class yourself. =head1 METHODS All exception objects have the following methods =head2 get_msg Returns a string with a descriptive error message, useful for outputting =head2 get_type The type of this error (e.g. "DocNotFoundError"). =head2 get_context Optional context information, returned as a string =head2 get_error_string Returns any error string from errno or similar associated with this error =cut use 5.006; use strict; use warnings; require DynaLoader; END foreach my $subclass (@{$subclasses{'Error'}}) { print F "use Search::Xapian::$subclass;\n"; } print F <<'END'; our @ISA = qw(DynaLoader); # Preloaded methods go here. # In a new thread, copy objects of this class to unblessed, undef values. sub CLONE_SKIP { 1 } sub new { my $class = shift; my ($self); bless $self, $class; return $self; } 1; END close F or die $!; rename "$fnm.tmp", "$fnm" or die $!; foreach ('Error', @baseclasses, @classes) { my ($classname, $parent, $full_description) = split /\t/; # XS/CLASSNAME.xs $fnm = "XS/$classname.xs"; open F, '>', "$fnm.tmp" or die $!; print F <<"END"; MODULE = Search::Xapian\t PACKAGE = Search::Xapian::$classname PROTOTYPES: ENABLE string ${classname}::get_type() string ${classname}::get_msg() string ${classname}::get_context() const char * ${classname}::get_error_string() void ${classname}::DESTROY() END if (exists $subclasses{$classname}) { print F "\n"; foreach my $subclass (@{$subclasses{$classname}}) { print F "INCLUDE: XS/$subclass.xs\n"; } } close F or die $!; rename "$fnm.tmp", "$fnm" or die $!; next if $classname eq 'Error'; $full_description =~ s!^[/ ]\*[*/]?!!mg; $full_description =~ s!\*\/$!!mg; # ! to unconfuse vim my ($heading, $desc) = split('\n\n', $full_description, 2); $desc ||= ''; # Xapian/CLASSNAME.pm $fnm = "Xapian/$classname.pm"; open F, '>', "$fnm.tmp" or die $!; print F <<"END"; package Search::Xapian::$classname; =head1 NAME Search::Xapian::$classname - $heading =head1 DESCRIPTION $desc =cut use 5.006; use strict; use warnings; require DynaLoader; # For compatibility with XS Search::Xapian < 1.2.3 which still threw strings # in some cases. use overload '""' => sub { "Exception: ".\$_[0]->get_msg }; END if (exists $subclasses{$classname}) { foreach my $subclass (@{$subclasses{$classname}}) { print F "use Search::Xapian::$subclass;\n"; } print F "\n"; } print F <<"END"; our \@ISA = qw(DynaLoader Search::Xapian::$parent); 1; END close F or die $!; rename "$fnm.tmp", "$fnm" or die $!; } # write new handle_exception.cc $fnm = "handle_exception.cc"; open F, '>', "$fnm.tmp" or die $!; print F <<'END'; #include extern "C" { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" } /* handle_exception function * * called in catch blocks to croak or rethrow in perl land */ void handle_exception(void) { try { throw; END foreach (reverse @classes) { my ($classname, $parent, $full_description) = split /\t/; print F <<"END"; } catch (const Xapian::$classname & error) { SV * errsv = get_sv("\@", TRUE); sv_setref_pv(errsv, "Search::Xapian::$classname", (void *) new Xapian::$classname(error)); croak(Nullch); END } print F <<'END'; } catch (const std::exception & error) { croak( "std::exception: %s", error.what()); } catch (...) { croak("something terrible happened"); } } END close F or die $!; rename "$fnm.tmp", "$fnm" or die $!; Search-Xapian-1.2.25.5/typemap0000644000175000017500000002072213320553070014512 0ustar ollyollyTYPEMAP Database O_DATABASE Database * O_DATABASE WritableDatabase O_WDATABASE WritableDatabase * O_WDATABASE Enquire * O_OBJECT Query O_QUERY Query * O_QUERY QueryParser O_QUERYPARSER QueryParser * O_QUERYPARSER TermGenerator O_TERMGENERATOR TermGenerator * O_TERMGENERATOR Stopper O_STOPPER Stopper * O_STOPPER SimpleStopper O_SIMPLESTOPPER SimpleStopper * O_SIMPLESTOPPER Stem O_OBJECT Stem * O_OBJECT MSet O_MSET MSet * O_MSET RSet O_RSET RSet * O_RSET ESet O_ESET ESet * O_ESET MSetIterator O_MSET_I MSetIterator * O_MSET_I ESetIterator O_ESET_I ESetIterator * O_ESET_I Document O_DOC Document * O_DOC MatchDecider O_OBJECT MatchDecider * O_OBJECT Weight O_WEIGHT Weight * O_WEIGHT BM25Weight O_WEIGHT BM25Weight * O_WEIGHT BoolWeight O_WEIGHT BoolWeight * O_WEIGHT TradWeight O_WEIGHT TradWeight * O_WEIGHT TermIterator O_TERM_I TermIterator * O_TERM_I PostingIterator O_POSTING_I PostingIterator * O_POSTING_I PositionIterator O_POSITION_I PositionIterator * O_POSITION_I ValueIterator O_VALUE_I ValueIterator * O_VALUE_I Error O_OBJECT Error * O_OBJECT ValueRangeProcessor O_OBJECT ValueRangeProcessor * O_OBJECT DateValueRangeProcessor O_OBJECT DateValueRangeProcessor * O_OBJECT NumberValueRangeProcessor O_OBJECT NumberValueRangeProcessor * O_OBJECT StringValueRangeProcessor O_OBJECT StringValueRangeProcessor * O_OBJECT MultiValueSorter O_SORTER MultiValueSorter * O_SORTER MultiValueKeyMaker O_SORTER MultiValueKeyMaker * O_SORTER MatchSpy O_MATCHSPY MatchSpy * O_MATCHSPY ValueCountMatchSpy O_MATCHSPY ValueCountMatchSpy * O_MATCHSPY string STRING docid T_UV doccount T_UV doclength T_UV termcount T_UV termpos T_UV valueno T_UV INPUT STRING { STRLEN len; const char * tmp = SvPV($arg, len); $var.assign(tmp, len); } O_MSET if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::MSet\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::MSet\\\" object\" ); XSRETURN_UNDEF; } O_RSET if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::RSet\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::RSet\\\" object\" ); XSRETURN_UNDEF; } O_ESET if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::ESet\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::ESet\\\" object\" ); XSRETURN_UNDEF; } O_MSET_I if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::MSetIterator\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::MSetIterator\\\" object\" ); XSRETURN_UNDEF; } O_ESET_I if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::ESetIterator\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::ESetIterator\\\" object\" ); XSRETURN_UNDEF; } O_DOC if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::Document\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::Document\\\" object\" ); XSRETURN_UNDEF; } O_QUERY if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::Query\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::Query\\\" object\" ); XSRETURN_UNDEF; } O_QUERYPARSER if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::QueryParser\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::QueryParser\\\" object\" ); XSRETURN_UNDEF; } O_TERMGENERATOR if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::TermGenerator\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::TermGenerator\\\" object\" ); XSRETURN_UNDEF; } O_STOPPER if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::Stopper\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::Stopper\\\" object\" ); XSRETURN_UNDEF; } O_SIMPLESTOPPER if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::SimpleStopper\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::SimpleStopper\\\" object\" ); XSRETURN_UNDEF; } O_DATABASE if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::Database\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::Database\\\" object\" ); XSRETURN_UNDEF; } O_WDATABASE if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::WritableDatabase\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::WritableDatabase\\\" object\" ); XSRETURN_UNDEF; } O_TERM_I if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::TermIterator\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::TermIterator\\\" object\" ); XSRETURN_UNDEF; } O_POSTING_I if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::PostingIterator\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::PostingIterator\\\" object\" ); XSRETURN_UNDEF; } O_POSITION_I if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::PositionIterator\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::PositionIterator\\\" object\" ); XSRETURN_UNDEF; } O_VALUE_I if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::ValueIterator\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::ValueIterator\\\" object\" ); XSRETURN_UNDEF; } O_WEIGHT if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::Weight\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::Weight\\\" object\" ); XSRETURN_UNDEF; } O_SORTER if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::MultiValueSorter\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::MultiValueSorter\\\" object\" ); XSRETURN_UNDEF; } O_MATCHSPY if( sv_isobject($arg) && sv_derived_from($arg, \"Search::Xapian::MatchSpy\") ) $var = ($type)SvIV((SV*)SvRV( $arg )); else{ warn( \"${Package}::$func_name() -- $var is not a \\\"Search::Xapian::MatchSpy\\\" object\" ); XSRETURN_UNDEF; } OUTPUT STRING sv_setpvn((SV*)$arg, (char *) ($var.data()), ($var.size())); O_MSET sv_setref_pv( $arg, "Search::Xapian::MSet", (void*)$var ); O_WEIGHT sv_setref_pv( $arg, "Search::Xapian::Weight", (void*)$var ); O_RSET sv_setref_pv( $arg, "Search::Xapian::RSet", (void*)$var ); O_ESET sv_setref_pv( $arg, "Search::Xapian::ESet", (void*)$var ); O_MSET_I sv_setref_pv( $arg, "Search::Xapian::MSetIterator", (void*)$var ); O_ESET_I sv_setref_pv( $arg, "Search::Xapian::ESetIterator", (void*)$var ); O_DOC sv_setref_pv( $arg, "Search::Xapian::Document", (void*)$var ); O_QUERY sv_setref_pv( $arg, "Search::Xapian::Query", (void*)$var ); O_QUERYPARSER sv_setref_pv( $arg, "Search::Xapian::QueryParser", (void*)$var ); O_TERMGENERATOR sv_setref_pv( $arg, "Search::Xapian::TermGenerator", (void*)$var ); O_STOPPER sv_setref_pv( $arg, "Search::Xapian::Stopper", (void*)$var ); O_SIMPLESTOPPER sv_setref_pv( $arg, "Search::Xapian::SimpleStopper", (void*)$var ); O_DATABASE sv_setref_pv( $arg, "Search::Xapian::Database", (void*)$var ); O_WDATABASE sv_setref_pv( $arg, "Search::Xapian::WritableDatabase", (void*)$var ); O_TERM_I sv_setref_pv( $arg, "Search::Xapian::TermIterator", (void*)$var ); O_POSTING_I sv_setref_pv( $arg, "Search::Xapian::PostingIterator", (void*)$var ); O_POSITION_I sv_setref_pv( $arg, "Search::Xapian::PositionIterator", (void*)$var ); O_VALUE_I sv_setref_pv( $arg, "Search::Xapian::ValueIterator", (void*)$var ); O_SORTER sv_setref_pv( $arg, "Search::Xapian::MultiValueSorter", (void*)$var ); O_MATCHSPY sv_setref_pv( $arg, "Search::Xapian::MatchSpy", (void*)$var ); Search-Xapian-1.2.25.5/MANIFEST.SKIP0000644000175000017500000000073213756634740015026 0ustar ollyolly\.gitignore Makefile Makefile\.old MANIFEST\.old MANIFEST\.bak MANIFEST\.OLD MYMETA.json MYMETA.yml testdb testdb-exception testdb-exception-modified testdb-spell testdb-writabledatabase t/symbol-test/MYMETA.json t/symbol-test/MYMETA.yml t/symbol-test/SymbolTest.c t/symbol-test/SymbolTest.lo blib pm_to_blib .*\.o Xapian\.c Xapian\.bs Xapian\.lo handle_exception.cc handle_exception\.lo Search-Xapian-[0-9.]+\.tar\.gz Search-Xapian-[0-9.]+ html ld-wrapper makefile-pl-args Search-Xapian-1.2.25.5/README0000644000175000017500000000606213756635010014001 0ustar ollyollySearch::Xapian version 1.2.25.5 =============================== This is Search::Xapian, a Perl XS interface to the Xapian C++ search library. We're working to replace these hand-coded XS wrappers with wrappers generated with SWIG, which will allow new C++ API features to be wrapped for Perl more quickly and easily than currently. These new bindings are available in xapian-bindings 1.4.16 and later. They are mostly compatible with these bindings, but there are some differences - see the documentation of the new bindings for a list of the known differences. To assist people with migration these XS bindings can also be compiled against xapian-core 1.4.x, and aim to present the same Perl API as when compiled against xapian-core 1.2.x. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install By default, Makefile.PL looks for xapian-config on your PATH. You can specify a path for xapian-config by passing XAPIAN_CONFIG=/path/to/xapian-config on the command line after Makefile.PL. Similarly, you can specify a C++ compiler by passing CXX=/usr/local/bin/g++ after Makefile.PL, as well as CXXFLAGS and CPPFLAGS to add additional compiler flags. For example: perl Makefile.PL XAPIAN_CONFIG=/home/jim/bin/xapian-config CXX=g++-4.3 These values are stored in the generated Makefile and will be used if "make" causes "perl Makefile.PL" to be automatically rerun (e.g. if you modify Makefile.PL). (For compatibility with what Search::Xapian 1.0.3.0 and earlier required, XAPIAN_CONFIG and CXX can also be specified as environmental variables. Specifying them on the command line is preferred because it avoids issues with differing syntax between shells and having to export variables). DEPENDENCIES Search::Xapian currently requires Perl >= 5.6. To work well in a threaded Perl script (i.e. when "use threads;" is in use), Perl >= 5.8.7 is required. This module requires these other modules and libraries: The Xapian C++ search library, which can be downloaded by following the instructions on https://xapian.org/ - versions 1.2.x and 1.4.x are supported by Search::Xapian 1.2.24.0 and later. DOCUMENTATION Most of the classes have POD documentation, which you can view using perldoc or man (e.g. perldoc Search::Xapian::Database). The Perl API closely follows the C++ API in most places, so the documentation for Xapian itself is generally applicable: The "Getting Started with Xapian" guide is a worthwhile read, especially if you are new to Xapian: COPYRIGHT AND LICENCE Please report any bugs/suggestions to or use the Xapian bug tracker . Please do NOT use the CPAN bug tracker or mail any of the authors individually. Copyright (c) 2002,2003 Alex Bowley. All rights reserved. Copyright (c) 2003-2020 Olly Betts. All rights reserved. Copyright (c) 2010,2012 Adam Sjøgren This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Search-Xapian-1.2.25.5/exception_data.pm0000755000175000017500000001561113756405314016453 0ustar ollyolly# exception_data.pm: details of the exception hierarchy used by Xapian. # # Copyright (C) 2003,2004,2006,2007,2008,2009,2020 Olly Betts # Copyright (C) 2007 Richard Boulton # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA package exception_data; use Exporter; @ISA = qw(Exporter); @EXPORT = qw($copyright $generated_warning @baseclasses @classes %subclasses); $copyright = <<'EOF'; /* Copyright (C) 2003,2004,2006,2007,2009 Olly Betts * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ EOF $generated_warning = "/* Warning: This file is generated by $0 - do not modify directly! */\n"; @baseclasses = (); @classes = (); %subclasses = (); sub errorbaseclass { push @baseclasses, join("\t", @_); push @{$subclasses{$_[1]}}, $_[0]; } sub errorclass { push @classes, join("\t", @_); push @{$subclasses{$_[1]}}, $_[0]; } errorbaseclass('LogicError', 'Error', <<'DOC'); /** The base class for exceptions indicating errors in the program logic. * * A subclass of LogicError will be thrown if Xapian detects a violation * of a class invariant or a logical precondition or postcondition, etc. */ DOC errorclass('AssertionError', 'LogicError', <<'DOC'); /** AssertionError is thrown if a logical assertion inside Xapian fails. * * In a debug build of Xapian, a failed assertion in the core library code * will cause AssertionError to be thrown. * * This represents a bug in Xapian (either an invariant, precondition, etc * has been violated, or the assertion is incorrect!) */ DOC errorclass('InvalidArgumentError', 'LogicError', <<'DOC'); /** InvalidArgumentError indicates an invalid parameter value was passed to the API. */ DOC errorclass('InvalidOperationError', 'LogicError', <<'DOC'); /** InvalidOperationError indicates the API was used in an invalid way. */ DOC errorclass('UnimplementedError', 'LogicError', <<'DOC'); /** UnimplementedError indicates an attempt to use an unimplemented feature. */ DOC # RuntimeError and subclasses: errorbaseclass('RuntimeError', 'Error', <<'DOC'); /** The base class for exceptions indicating errors only detectable at runtime. * * A subclass of RuntimeError will be thrown if Xapian detects an error * which is exception derived from RuntimeError is thrown when an * error is caused by problems with the data or environment rather * than a programming mistake. */ DOC errorclass('DatabaseError', 'RuntimeError', <<'DOC'); /** DatabaseError indicates some sort of database related error. */ DOC errorclass('DatabaseCorruptError', 'DatabaseError', <<'DOC'); /** DatabaseCorruptError indicates database corruption was detected. */ DOC errorclass('DatabaseCreateError', 'DatabaseError', <<'DOC'); /** DatabaseCreateError indicates a failure to create a database. */ DOC errorclass('DatabaseLockError', 'DatabaseError', <<'DOC'); /** DatabaseLockError indicates failure to lock a database. */ DOC errorclass('DatabaseModifiedError', 'DatabaseError', <<'DOC'); /** DatabaseModifiedError indicates a database was modified. * * To recover after catching this error, you need to call * Xapian::Database::reopen() on the Database and repeat the operation * which failed. */ DOC errorclass('DatabaseOpeningError', 'DatabaseError', <<'DOC'); /** DatabaseOpeningError indicates failure to open a database. */ DOC errorclass('DatabaseVersionError', 'DatabaseOpeningError', <<'DOC'); /** DatabaseVersionError indicates that a database is in an unsupported format. * * From time to time, new versions of Xapian will require the database format * to be changed, to allow new information to be stored or new optimisations * to be performed. Backwards compatibility will sometimes be maintained, so * that new versions of Xapian can open old databases, but in some cases * Xapian will be unable to open a database because it is in too old (or new) * a format. This can be resolved either be upgrading or downgrading the * version of Xapian in use, or by rebuilding the database from scratch with * the current version of Xapian. */ DOC errorclass('DocNotFoundError', 'RuntimeError', <<'DOC'); /** Indicates an attempt to access a document not present in the database. */ DOC errorclass('FeatureUnavailableError', 'RuntimeError', <<'DOC'); /** Indicates an attempt to use a feature which is unavailable. * * Typically a feature is unavailable because it wasn't compiled in, or * because it requires other software or facilities which aren't available. */ DOC errorclass('InternalError', 'RuntimeError', <<'DOC'); /** InternalError indicates a runtime problem of some sort. */ DOC errorclass('NetworkError', 'RuntimeError', <<'DOC'); /** Indicates a problem communicating with a remote database. */ DOC errorclass('NetworkTimeoutError', 'NetworkError', <<'DOC'); /** Indicates a timeout expired while communicating with a remote database. */ DOC errorclass('QueryParserError', 'RuntimeError', <<'DOC'); /** Indicates a query string can't be parsed. */ DOC errorclass('SerialisationError', 'RuntimeError', <<'DOC'); /** Indicates an error in the std::string serialisation of an object. */ DOC errorclass('RangeError', 'RuntimeError', <<'DOC'); /** RangeError indicates an attempt to access outside the bounds of a container. */ DOC $::version >= 1003003 and errorclass('WildcardError', 'RuntimeError', <<'DOC'); /** WildcardError indicates an error expanding a wildcarded query. */ DOC $::version >= 1004010 and errorclass('DatabaseNotFoundError', 'DatabaseOpeningError', <<'DOC'); /** Indicates an attempt to access a database not present. */ DOC $::version >= 1004010 and errorclass('DatabaseClosedError', 'DatabaseError', <<'DOC'); /** Indicates an attempt to access a closed database. */ DOC 1; Search-Xapian-1.2.25.5/Makefile.PL0000644000175000017500000002212413756405331015071 0ustar ollyollyuse ExtUtils::MakeMaker; use strict; use Config; use File::Spec; my $builddir; my $srcdir = $0; if ($srcdir =~ s!/([^/]*)$!!) { # Set $0 to be just the leafname. If we don't, WriteMakefile() reruns this # script for reasons unknown, leading to a seemingly infinite loop # consuming increasing amounts of memory. With setting $0, it still reruns # this script, but only once. $0 = $1; $builddir = `pwd`; chdir $srcdir; if ($builddir eq `pwd`) { # Just an explicit path to the current directory. undef $builddir; } else { chomp($builddir); } } my $xapian_config; my $CC; my %var = (); my $devnull = File::Spec->devnull(); # Write out args for use by t/symboltest.t. open ARGS, '>', 'makefile-pl-args' or die $!; for (@ARGV) { print ARGS $_, "\n"; if (/^XAPIAN_CONFIG=(.*)/) { $xapian_config = $1; } elsif (/^CXX=(.*)/) { $CC = $1; } elsif (/^(C(?:XX|PP)FLAGS)=(.*)/) { $var{$1} = $2; } } close ARGS or die $!; if (!defined $xapian_config && exists $ENV{XAPIAN_CONFIG}) { $xapian_config = $ENV{XAPIAN_CONFIG}; push @ARGV, "XAPIAN_CONFIG=$xapian_config"; } $xapian_config ||= 'xapian-config'; if (!defined $CC && exists $ENV{CXX}) { $CC = $ENV{CXX}; push @ARGV, "CXX=$CC"; } $CC ||= 'g++'; my $LD = '$(CC)'; if ($^O eq 'cygwin' and $CC eq 'g++') { # Cygwin packages of Perl < 5.9.5 used "ld2" for $Config{ld} and # $Config{lddlflags} didn't contain -shared so we need to specify # this explicitly. Perl >= 5.9.5 package do away with "ld2", but # it should be harmless to specify "-shared" there. $LD = 'g++ -shared'; } my $xver = `$xapian_config --version`; if ($xver eq '') { print STDERR < "1.2.0" my $inc = `$xapian_config --cxxflags`; chomp($inc); my @writemakefile_args = (); my $libsvar = 'LIBS'; my $libs = `$xapian_config --libs 2> $devnull`; chomp($libs); my ($xapian_config_dir) = $xapian_config =~ /^(.*?)[^\/]*$/; if ($? || ($xapian_config_dir ne '' && -f "${xapian_config_dir}Makefile")) { # Assume we're being asked to build against an uninstalled xapian-core. my $libtool = "${xapian_config_dir}libtool"; unless (-x $libtool) { die "You've asked me to link against what appears to be an uninstalled xapian-core tree, but I can't find libtool in that tree\n"; } # We can't pass a .la file in LIBS since MakeMaker "knows better" and # ignores it. Passing it in LDLOADLIBS works, but generates a warning. # We can avoid the warning by setting LDLOADLIBS using 'macro'. $libsvar = 'macro'; $libs = `$xapian_config --ltlibs`; chomp($libs); $libs = {'LDLOADLIBS' => $libs}; open LDWRAP, '>', 'ld-wrapper' or die $!; print LDWRAP < '.lo', 'DLEXT' => 'la' ); } system($^X, "generate-perl-exceptions", ".", $xver) == 0 or die "Running generate-perl-exceptions failed: $?"; # Filter out some gcc options which g++ doesn't support. my $CCFLAGS = $Config{'ccflags'}; # Perl is built with -Wdeclaration-after-statement on RHEL5 - this isn't # meaningful for C++ - it only emits a warning but it's easy to fix. $CCFLAGS =~ s/(?:^|\s+)-Wdeclaration-after-statement(?:\s+|$)/ /; # The generated code causes "variable may be used uninitialized" warnings # if Perl was built with -Wall. $CCFLAGS =~ s/(^|\s+)-Wall(\s+|$)/$1-Wall -Wno-uninitialized$2/; if (exists $var{CPPFLAGS}) { $CCFLAGS .= ' ' . $var{CPPFLAGS}; } elsif (exists $ENV{CPPFLAGS}) { $CCFLAGS .= ' ' . $ENV{CPPFLAGS}; } if (exists $var{CXXFLAGS}) { $CCFLAGS .= ' ' . $var{CXXFLAGS}; } elsif (exists $ENV{CXXFLAGS}) { $CCFLAGS .= ' ' . $ENV{CXXFLAGS}; } # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. push @writemakefile_args, ( 'NAME' => 'Search::Xapian', 'VERSION_FROM' => 'Xapian.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'Xapian.pm', # retrieve abstract from module AUTHOR => 'Alex Bowley ') : ()), # AUTHOR => 'Alex Bowley ') : ()), 'META_MERGE' => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', web => 'https://git.xapian.org/?p=xapian;a=tree;f=search-xapian;hb=refs/heads/svn/1.2' }, bugtracker => { web => 'https://trac.xapian.org/' }, homepage => 'https://xapian.org/', }, }, $libsvar => $libs, # e.g., '-lm' 'LICENSE' => 'perl', 'MIN_PERL_VERSION' => '5.6.0', 'BUILD_REQUIRES' => { 'Devel::Leak' => 0 }, 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' 'CC' => $CC, 'CCFLAGS' => $CCFLAGS, 'LD' => $LD, 'INC' => $inc, # e.g., '-I/usr/include/other' 'OBJECT' => '$(BASEEXT)$(OBJ_EXT) handle_exception$(OBJ_EXT)', 'XSOPT' => '-C++', # 'typemap' is implicitly added to this list. 'TYPEMAPS' => ['perlobject.map', 'typemap-errorclasses'], 'clean' => { 'FILES' => 'ld-wrapper makefile-pl-args' }, # Add "make check" as alias for "make test". # Make sure that we rebuild the Makefile if the version number changes. 'depend' => { 'check' => 'test', 'Makefile' => 'Xapian.pm' }, ); # Throw away STDOUT from WriteMakefile() to suppress warnings about parameters # we allow the user to specify: CPPFLAGS CXX CXXFLAGS XAPIAN_CONFIG *TEMP = *STDOUT; open DEVNULL, '>', $devnull; *STDOUT = *DEVNULL; WriteMakefile(@writemakefile_args); *STDOUT = *TEMP; close DEVNULL; my $VERSION = "unknown"; open F, "Makefile" or die $!; while () { if (/^VERSION\s*=\s*(\S*)/) { $VERSION = $1; last; } } close F; my ($BASEVERSION) = $VERSION =~ /^([0-9]+\.[0-9]+\.[0-9]+)/; if ($xver !~ /^\Q$BASEVERSION\E(?:_(?:svn|git)[0-9]+)?$/) { # We definitely need Xapian 1.2.x, 1.4.x, 1.5.x or 1.6.x. my $no_chance = ($xver !~ /^1\.[2456]\./); my $msg; if ($no_chance) { $msg = "Xapian version $xver is incompatible with Search::Xapian $VERSION\n"; } elsif ($BASEVERSION =~ /^1\.2\./ && $xver =~ /^1\.4\./) { # Search::Xapian 1.2.x and xapian-core 1.4.y should work together # (for x >= 24). } else { # We try to keep working with Xapian 1.5.x and up but no promises. $msg = "Xapian version $xver may be incompatible with Search::Xapian $VERSION\n"; } if ($ENV{AUTOMATED_TESTING} && defined $msg) { # Don't let automated testers continue, as we don't want bogus failure # reports due to builds with incompatible versions. print $msg; # Remove Makefile since "exit status 0 without generating Makefile" # is taken to indicate "can't build because of missing dependencies" # by CPAN test building scripts. unlink "Makefile"; exit 0; } if ($no_chance) { unlink "Makefile"; die $msg; } warn "Warning: $msg" if defined $msg; } my @bad; for my $file (qw(Changes README)) { open F, $file or next; my $ok; while () { if (/\b\Q$VERSION\E\b/) { $ok = 1; last; } } close F; if (!$ok) { push @bad, $file; } } if (scalar @bad) { unlink "Makefile"; die(join(",",@bad).": No mention of current version: $VERSION\n"); } # If we're doing a fake VPATH build, add a stub Makefile which forwards all # invocations (.DEFAULT is a GNU-make-ism). if (defined $builddir) { open M, '>', "$builddir/Makefile~" or die $!; print M <<"EOF"; all .DEFAULT: \t\$(MAKE) -C "$srcdir" \$\@ .PHONY: all Search-Xapian-$VERSION.tar.gz dist tardist Search-Xapian-$VERSION.tar.gz: \t\$(MAKE) -C "$srcdir" \$\@ \trm -f Search-Xapian-$VERSION.tar.gz \tcp "$srcdir"/Search-Xapian-$VERSION.tar.gz . EOF close M or die $!; rename "$builddir/Makefile~", "$builddir/Makefile" or die $!; } sub MY::postamble { return "\$(XS_FILES): ".join(" ", )."\n\ttouch \$(XS_FILES)"; } Search-Xapian-1.2.25.5/META.yml0000644000175000017500000000137214207007026014361 0ustar ollyolly--- abstract: 'Perl XS frontend to the Xapian C++ search library.' author: - 'Alex Bowley ' build_requires: Devel::Leak: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Search-Xapian no_index: directory: - t - inc requires: perl: '5.006000' resources: bugtracker: https://trac.xapian.org/ homepage: https://xapian.org/ repository: https://git.xapian.org/?p=xapian;a=tree;f=search-xapian;hb=refs/heads/svn/1.2 version: v1.2.25.5 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Search-Xapian-1.2.25.5/Changes0000644000175000017500000010660114207006637014413 0ustar ollyollyRevision history for Perl extension Search::Xapian. 1.2.25.5 Sun Feb 27 23:46:46 UTC 2022 [Changes contributed by Olly Betts] - The exception fix in 1.2.25.3 unintentionally broke the build with xapian-core < 1.4.10. To fix this we now generate the exception handling code at build time, and enable the new exceptions based on the version of xapian-core we're building against. 1.2.25.4 Thu Nov 19 23:37:21 UTC 2020 [Changes contributed by Olly Betts] - Add exception-related files which were new in 1.2.25.3 to MANIFEST so they're shipped. Reported by Tina Müller and Leah Neukirchen. - Add metadata links to homepage, bugtracker and VCS. Suggested by Gabor Szabo. 1.2.25.3 Tue Nov 17 00:33:44 UTC 2020 [Changes contributed by Alyssa Ross] - Allow AUTOMATED_TESTING builds against xapian-core 1.4.x. [Changes contributed by Olly Betts] - Properly handle newer exceptions. The C++ exception class WildcardError wasn't known to the Perl bindings, and would result in croak("something terrible happened"). The C++ exception classes DatabaseClosedError and DatabaseNotFoundError also weren't known, but these would instead be reported as their base classes DatabaseError and DatabaseOpeningError respectively. Reported by Adam Sjøgren. - README: Update to reflect that the SWIG-generated Perl bindings are stable since xapian-bindings 1.4.16. 1.2.25.2 Wed Sep 19 23:58:12 UTC 2018 [Changes contributed by Olly Betts] - Fix to build against Xapian <= 1.4.1 again, broken by changes in 1.2.25.1. Reported by Jim Lynch. 1.2.25.1 Mon Jul 9 03:29:14 UTC 2018 [Changes contributed by Olly Betts] - Skip testcase t/parser.t if we're using xapian-core < 1.2.21 which doesn't support character '!' in the start of a range. Reported by melmothx on #xapian. - Add compatibility with Xapian git master. 1.2.25.0 Tue Sep 26 02:06:18 UTC 2017 [Changes contributed by Olly Betts] - Wrap WritableDatabase::commit(), which is the preferred name for WritableDatabase::flush(). - Fix long SEE ALSO lines by putting a newline after each comma in the SEE ALSO lists, fixing warnings from man such as: :109: warning [p 1, 8.0i]: can't break line - Backport some improvements to the POD documentation from the SWIG-based bindings in xapian-bindings 1.4.x. - Avoid perl -W in tests as that seems to break recent versions of Test::More. - Suppress dummy warning using undef value when building against xapian-core 1.4.x. 1.2.24.0 Fri Sep 16 01:46:36 UTC 2016 [Changes contributed by Nick Morrott] - Fix typo in POD documentation (fixes #730). [Changes contributed by Olly Betts] - Allow building against xapian-core 1.4.x as well as xapian-core 1.2.x. 1.2.23.0 Mon Mar 28 08:44:59 UTC 2016 [Changes contributed by Olly Betts] - makehtmldocs: Fix inter-class links in generated HTML. - Fix typo in POD documentation. - Update Xapian website and trac links to use https, which is now supported, thanks to James Aylett. 1.2.22.0 Tue Dec 29 06:05:40 UTC 2015 [Changes contributed by Val Rosca, updated by Andreas Marienborg] - Wrap MatchSpy and ValueCountMatchSpy classes - Wrap Enquire's add_matchspy and clear_matchspies methods, keeping track of references to Perl MatchSpy objects to avoid leaks. - t/facets.t [Changes contributed by Olly Betts] - Fix infinite loop trying to build with CPANPLUS (fixes #692, reported by Andreas Vögele). - t/termgenerator.t: If a memory leak is detected, report how many objects were allocated before and after the test. - Allow for "_gitN" tag on snapshots when checking for version compatibility with xapian-core. - META.yml: Fix specified licence to be a valid name ('perl' instead of 'perl_5'). 1.2.21.0 Wed May 20 14:34:41 UTC 2015 [Changes contributed by Olly Betts] - Support passing collapse_max argument to Enquire::set_collapse_key(). Fixes #669, reported by Felix Ostmann. - Add missing 'my' to testcases. - Add 'use strict' to all testcases. - Add a "LICENSE" section to the main POD. - META.yml: Specify licence and minimum Perl version. - Fix t/symboltest.t to work when built against an installed version of xapian-core (broken by changes in 1.2.20.0). - Fix "Filehandle STDOUT reopened as M only for input" warning from running "perl Makefile.PL". 1.2.20.0 Wed Mar 4 00:30:08 UTC 2015 [Changes contributed by Olly Betts] - Remove TODO for wrapping MatchAll and MatchNothing - these were added in 1.2.13.0. Reported by Will Crawford. - Wrap Xapian::BAD_VALUENO. - Fix "make test" to use the Xapian.so we just built, rather than an installed version. 1.2.19.0 Tue Oct 21 00:35:35 UTC 2014 [Changes contributed by Dmitry Karasik] - Fix deliberate leaks in QueryParser::add_valuerangeprocessor() and QueryParser::set_stopper() by tracking object ownership properly. (ticket#647) [Changes contributed by Olly Betts] - Fix deliberate leaks in TermGenerator::set_stopper() and Enquire methods which allow specifying a Sorter object similarly. 1.2.18.0 Sun Jun 22 06:39:55 UTC 2014 [Changes contributed by Olly Betts] - README: Add link to "Getting Started with Xapian". - Mass whitespace clean-up. 1.2.17.0 Wed Jan 29 00:00:00 UTC 2014 - No change except for bumping the version to indicate compatibility with Xapian 1.2.17. 1.2.16.0 Wed Dec 4 00:00:00 UTC 2013 [Changes contributed by Olly Betts] - t/symbol-test/Makefile.PL: Pass $CPPFLAGS and $CXXFLAGS from the environment through to the sub-build, fixing symbol-test.t failure when built with CPPFLAGS=-D_GLIBCXX_DEBUG. 1.2.15.0 Tue Apr 16 23:43:24 UTC 2013 [Changes contributed by Olly Betts] - Remove superfluous duplicate method wrappers from WritableDatabase for methods wrapped in Database parent class. - Improve test coverage. - Fix minor typo in POD documentation. 1.2.14.0 Thu Mar 14 23:12:38 UTC 2013 [Changes contributed by Olly Betts] - Perl 5.16.1 adds a '.' after "at foo line 123" so adjust regexp in testcase t/10query.t to allow an optional '.' there. (ticket#610) 1.2.13.0 Wed Jan 9 11:19:20 UTC 2013 [Changes contributed by Adam Sjøgren] - Wrap 2 and 3 parameter forms of StringValueRangeProcessor constructor so prefixes and suffixes can be specified. (ticket#607) [Changes contributed by Olly Betts] - Wrap the zero argument Query constructor. - Add wrappers for Query::MatchAll and Query::MatchNothing. - Don't pointlessly reinitialise default std::string parameters to an empty string (performance and code size micro-optimisation). 1.2.12.0 Wed Jun 27 12:17:26 UTC 2012 - No change except for bumping the version to indicate compatibility with Xapian 1.2.12. 1.2.11.0 Tue Jun 26 12:13:39 UTC 2012 - No change except for bumping the version to indicate compatibility with Xapian 1.2.11. 1.2.10.0 Wed May 9 10:45:51 UTC 2012 [Changes contributed by Olly Betts] - Wrap Database::close() (was previously only wrapped for WritableDatabase). - Suppress warnings about "not a known MakeMaker parameter name" in a way which also works for newer versions of Perl. 1.2.9.0 Thu Mar 8 07:19:27 UTC 2012 [Changes contributed by Olly Betts] - Wrap Document::get_docid() method. - Fix "Use of qw(...) as parentheses is deprecated" warnings in tests with Perl 5.14. - Improve test coverage of TermGenerator (backported from trunk). 1.2.8.0 Tue Dec 13 14:45:07 UTC 2011 [Changes contributed by Olly Betts] - Add note to README about documentation, pointing out that the docs for Xapian are useful. - Improve note in README about moving to SWIG-generated wrappers in the next release series. 1.2.7.0 Wed Aug 10 06:14:53 UTC 2011 [Changes contributed by Olly Betts] - Note in README that the hand-coded XS wrappers are heading for retirement. 1.2.6.0 Sun Jun 12 11:55:42 UTC 2011 [Changes contributed by Adam Sjøgren] - Wrap new method QueryParser::set_max_wildcard_expansion(). (ticket#350) 1.2.5.0 Mon Apr 4 14:00:38 UTC 2011 [Changes contributed by Olly Betts] - simpleindex.pl - use 'while' to loop over input lines - 'foreach' reads them all in and then loops over them, while reads and processes line by line. - Add '1;' to the end of t/symbol-test/SymbolTest.pm. 1.2.4.0 Thu Dec 19 12:41:49 UTC 2010 [Changes contributed by Olly Betts] - Xapian exceptions were still being thrown as strings in Perl in some cases. Now all cases throw a subclass of Search::Xapian::Error. For compatibility with code which expects the previous behaviour these subclasses auto-stringify to the string which would have been thrown before. - Make sure all Perl files have 'use strict;' and 'use warnings;'. - Remove superfluous 'use Carp;' from generated error classes. - t/document.t,t/index.t,t/search.t: Test TermIterator::get_termname(). - Makefile.PL now looks for CXXFLAGS and CPPFLAGS passed on the command line, and adds them to CCFLAGS in the generated Makefile. [Changes contributed by Tim Brody] - New testcase t/10query.t. [Changes contributed by David F. Skoll and Dave O'Neill] - Tell DynaLoader to load the module with RTLD_GLOBAL so exceptions still work when multiple Perl modules which link to xapian-core are loaded. (ticket#522) 1.2.3.0 Tue Aug 24 06:03:12 UTC 2010 [Changes contributed by Tim Brody] - Allow user-specified ExpandDecider to be specified to get_eset(). [Changes contributed by Jess Robinson] - Fix bogus "can't find libtool" error when rerunning Makefile.PL and XAPIAN_CONFIG isn't explicitly specified. 1.2.2.0 Sun Jun 27 03:31:36 UTC 2010 - No change except for bumping the version to indicate compatibility with Xapian 1.2.2. 1.2.1.0 Tue Jun 22 14:48:00 UTC 2010 - No change except for bumping the version to indicate compatibility with Xapian 1.2.1. 1.2.0.0 Wed Apr 28 10:44:15 UTC 2010 [This release includes all changes from 1.0.20 which are relevant.] 1.1.5.0 Thu Apr 15 04:23:16 UTC 2010 [This release includes all changes from 1.0.19 which are relevant.] 1.1.4.0 Mon Feb 15 14:08:51 UTC 2010 [This release includes all changes from 1.0.18 which are relevant.] [Changes contributed by Henry Combrinck] - Add wrappers for the spelling correction functionality (ticket#420). - Add wrapper for Database::close() (ticket#422). 1.1.3.0 Wed Nov 18 11:00:23 UTC 2009 [This release includes all changes from 1.0.15-17 which are relevant.] [Changes contributed by Olly Betts] - Wrap new Xapian::SerialisationError class. - Ship simplematchdecider.pl example, which was added in 1.0.13.1 but accidentally not added to 1.1.1.0. - Work around odd rerunning of Makefile.PL by MakeMaker when srcdir != builddir. 1.1.2.0 Thu Jul 23 04:14:29 UTC 2009 [This release includes all changes from 1.0.14 which are relevant.] 1.1.1.0 Tue Jun 9 13:22:07 UTC 2009 [Changes contributed by Olly Betts] - Add Search::Xapian::MSet::items() method which returns an array tied to the MSet (much like Search::Xapian::Enquire::matches(), but you get easy access to the MSet object itself too). - Add the ability to tie an ESet to an array and a new Search::Xapian::ESet::items() method to make use of it. - Add new translated version of the simple examples from the Python bindings. - Add more fully featured examples: full-indexer.pl and full-searcher.pl. - Add better test coverage for MatchDecider. - Catch C++ exceptions from methods of Document and rethrow as Perl exceptions (ticket#284). - Add dependency to regenerate Makefile if Xapian.pm changes (since the former contains a version number extracted from the latter). 1.1.0.0 Thu Apr 22 13:56:31 GMT 2009 [Changes contributed by Andreas Marienborg and Olly Betts] - Xapian C++ exceptions classes are now wrapped and C++ exceptions are caught and rethrown in Perl as the wrapped classes. [Changes contributed by Olly Betts] - Xapian-core now uses libtool 2.2.x, which has required changes to the how we cram libtool into the MakeMaker-generated Makefile. However, there's still a wrinkle in this change - you can't currently run "make install" in a tree configured to use an uninstalled xapian-core. 1.0.23.0 Fri Jan 14 04:18:24 UTC 2011 [Changes contributed by David F. Skoll and Dave O'Neill] - Tell DynaLoader to load the module with RTLD_GLOBAL so exceptions still work when multiple Perl modules which link to xapian-core are loaded (ticket#522). 1.0.22.0 Sun Oct 3 12:36:44 UTC 2010 [Changes contributed by Jess Robinson] - Fix bogus "can't find libtool" error when rerunning Makefile.PL and XAPIAN_CONFIG isn't explicitly specified. [Changes contributed by Tim Brody] - New testcase t/10query.t. 1.0.21.0 Fri Jun 18 16:41:32 UTC 2010 - No change except for bumping the version to indicate compatibility with Xapian 1.0.21. 1.0.20.0 Tue Apr 27 12:35:35 UTC 2010 [Changes contributed by Olly Betts] - Avoid importing isa from UNIVERSAL to fix Perl 5.12 deprecation warning (Debian bug#578559). - Fix testcase t/04functions.t to work with Perl compiled with -Duselongdouble (Debian bug#578558). 1.0.19.0 Thu Apr 15 03:55:04 UTC 2010 [Changes contributed by Olly Betts] - Wrap Document::add_boolean_term() (new in C++ API in 1.0.18). - Add test coverage for Document::remove_term(). 1.0.18.0 Sun Feb 14 10:22:53 UTC 2010 [Changes contributed by Henry Combrinck] - Add wrappers for the spelling correction functionality (ticket#420). 1.0.17.0 Wed Nov 18 02:02:41 UTC 2009 [Changes contributed by Olly Betts] - Fix to build with compilers other than GCC by disabling Perl's #define for bool. (ticket#404) 1.0.16.0 Thu Sep 10 06:26:08 UTC 2009 [Changes contributed by Olly Betts] - Improve documentation of QueryParser::set_default_op() and QueryParser::get_default_op(). - examples/: Use MSet::items() (new in 1.0.13.1). - examples/simpleexpand.pl: Remove debug print statement left in by accident. - Add dependency to regenerate Makefile if Xapian.pm changes (since the former contains a version number extracted from the latter). - Add better test coverage for MatchDecider. 1.0.15.0 Wed Aug 26 14:59:31 GMT 2009 [Changes contributed by Frank Lichtenheld] - Run POD coverage tests if TEST_POD_COVERAGE is set rather than TEST_POD so that the other POD tests can easily be enabled without enabling the coverage tests. 1.0.14.0 Tue Jul 21 16:10:19 GMT 2009 [Changes contributed by Olly Betts] - Add handling of C++ exceptions from methods of Document (ticket#284). 1.0.13.1 Tue May 26 13:51:18 GMT 2009 [Changes contributed by Olly Betts] - Deprecate Search::Xapian::MSet::matches() and make it issue a warning. Please use Search::Xapian::MSet::items() instead. - Add another translated example: simplematchdecider.pl 1.0.13.0 Sat May 23 15:10:39 GMT 2009 [Changes contributed by Olly Betts] - Add Search::Xapian::MSet::matches() method which returns an array tied to the MSet (much like Search::Xapian::Enquire::matches(), but you get access to the MSet object itself). - Add new translated version of the simple examples from the Python bindings. - Add more fully featured examples: full-indexer.pl and full-searcher.pl. 1.0.12.0 Sun Apr 19 11:18:04 GMT 2009 [Changes contributed by Olly Betts] - Add handling of exceptions from Database::get_metadata() and methods of Enquire which might throw DatabaseModifiedError to address situation reported in ticket#284. - Skip thread.t testcase if Perl is new enough, but wasn't built with thread support (reported by Felix Antonius Wilhelm Ostmann). - Fix "fake VPATH" mode to work better. [Changes contributed by Kosei Moriyama] - Add test coverage for more WritableDatabase methods. 1.0.11.0 Sun Mar 15 12:53:20 GMT 2009 [Changes contributed by Olly Betts] - Wrap the new FLAG_DEFAULT constant which gives the QueryParser default flag settings, allowing you to easily add flags to the default ones. 1.0.10.0 Tue Dec 23 09:18:21 GMT 2008 [Changes contributed by Olly Betts] - Makefile.PL now supports a "fake VPATH" mode, to better support for building from SVN. If you run "perl /path/to/Makefile.PL" then Makefile.PL will run Makefile.PL as nomal in /path/to, and then create a stub Makefile in the current directory which forwards any make invocations. 1.0.9.0 Fri Oct 31 23:27:06 GMT 2008 [Changes contributed by Olly Betts] - Wrap Search::Xapian::get_major_version(), get_minor_version(), get_revision(), sortable_serialise(), and sortable_unserialise(). - Reject xapian-core < 1.0 with an error rather than just a warning. 1.0.8.0 Thu Sep 4 05:38:22 GMT 2008 - No change except for bumping the version to indicate compatibility with Xapian 1.0.8. 1.0.7.0 Thu Jul 17 00:18:17 GMT 2008 [Changes contributed by Olly Betts] - Handle exceptions from Xapian::Stem constructor (reported by Joey Hess in Debian BTS #486138). - Fix testcase in t/parser.t for improved behaviour of xapian-core. - Actually fill in @Search::Xapian::DB_NAMES. - Search::Xapian::Query->new(, ) now allows integers and numbers as terms - these are coerced to strings as with standard Perl parameter passing. 1.0.6.0 Sun Mar 30 10:20:58 GMT 2008 [Changes contributed by Olly Betts] - If the Search::Xapian and xapian-config versions don't match, and $ENV{AUTOMATED_TESTING} is true, then we need to unlink Makefile as well as exiting with status 0. - Mention QueryParser flags in POD: FLAG_SPELLING_CORRECTION, FLAG_SYNONYM, FLAG_AUTO_SYNONYMS, and FLAG_AUTO_MULTIWORD_SYNONYMS. - Removed no-op method Enquire::register_match_decider() which is now deprecated in C++. It doesn't do anything, and never has, so if you were calling it, you can just remove the call! - Improve POD for Enquire::get_eset(). - Increment the reference counts of Sorter objects passed to methods of Enquire. This means we'll leak them, but that's better than having them garbage collected while the C++ code is still using them. This will be fixed properly in a future release. - You can now construct a Query from a mixed list of Query objects and strings (previously the list had to be all Query objects or all strings). - Don't accept values with a leading '-' or '+' for OP_* constants - users should be using the defined constants for these which are all positive without an explicit '+'. - Wrap OP_SCALE_WEIGHT, OP_VALUE_GE, OP_VALUE_LE, and the corresponding Query constructor overloads. [Changes contributed by Matthew Somerville] - Wrap optional prefix argument to WritableDatabase::allterms_begin() and WritableDatabase::allterms_end(). 1.0.5.0 Wed Jan 02 01:07:28 GMT 2008 [Changes contributed by Olly Betts] - Suppress MakeMaker warnings if CXX and/or XAPIAN_CONFIG are specified. - If CXX and/or XAPIAN_CONFIG are specified in the environment, we make sure that they are preserved in Makefile.PL is rerun. - If xapian-config isn't found, Makefile.PL now exits with status 0 which CPAN tester script understand to mean "missing dependencies". - If the Search::Xapian and xapian-config versions don't match, the usual warning is replaced by an error and exit with status 0 if $ENV{AUTOMATED_TESTING} is true. - Emphasise in the README and POD that bug reports should be sent to the xapian-discuss mailing list or Xapian bug tracker, not to the CPAN bug tracker or individual authors. - "use Exporter 'import';" rather than inheriting from Exporter to avoid pulling other symbols in. - Rejig the constructors of the ValueRangeProcessor subclasses so that they should work with Perl 5.6 too. - Wrap MultiValueSorter and Enquire::set_sort_by_key(), etc. - Minor documentation improvements. - Enhance t/parser.t to check results of NumberValueRangeProcessor. - Fix QueryParser::parse_query() to catch Xapian::Error rather than const char * - it stopped throwing const char * in Xapian 1.0.0 (bug#221). - Wrap TermGenerator methods: set_database() and set_flags(). [Changes contributed by Rusty Conover] - Wrap QueryParser flags: FLAG_SPELLING_CORRECTION, FLAG_SYNONYM, FLAG_AUTO_SYNONYMS, and FLAG_AUTO_MULTIWORD_SYNONYMS. - Wrap WritableDatabase methods: add_synonym(), remove_synonym(), and clear_synonyms(). - Wrap TermGenerator::FLAG_SPELLING and TermGenerator::set_database(). 1.0.4.0 Wed Oct 31 23:18:02 GMT 2007 [Changes contributed by Olly Betts] - Add all the POD pages to the "see also" on the main POD page. - Fix typos and improve wording throughout the POD documentation. - Add POD documentation for ValueIterator. - Makefile.PL now accepts XAPIAN_CONFIG and CXX on the command line (like autoconf configure scripts) and values specified here are persistent across automatic reruns, so promote this usage over environmental variables. - Compiling with GCC 4.2 gives many "deprecated conversion from string constant to 'char*'" warnings. Most are from XS-generated code, but fix the small number which aren't. - Make Search::Xapian work with 'use threads;' by adding 'sub CLONE_SKIP { 1 }' to all the classes (this requires Perl >= 5.8.7 to work, but has no effect on older versions). Using CLONE_SKIP means that Xapian objects aren't copied to subthreads, so the wrapped C++ objects don't get destroyed more than once. Thanks to Ron Kass for suggesting this change. - Add testcase thread.t to check that threaded use works as expected under Perl 5.8.7. - BoolWeight objects are now blessed as class BoolWeight rather than class Weight. - Fix test parser.t to match the fixed behaviour of STEM_ALL. - Cleaned up unnecessary 'require Exporter;' and 'use Carp;'. - Move the POD documentation to the end of the pm files and insert __END__ before them. - A script to generate interlinked HTML documentation has been added (called makehtmldocs). 1.0.3.0 Sat Sep 29 13:26:32 BST 2007 [Changes contributed by Olly Betts] - Wrap Database::get_metadata() and WritableDatabase::set_metadata(). - Improve QueryParser pod documentation. - PerlStopper::operator() now declared const as it should be. - Suppress "deprecated" warnings from Xapian since we need to keep wrapping deprecated features. - Suppress compilation warnings on some Linux distros. - Add Xapian.lo to MANIFEST.SKIP (it's generated if we're building against an uninstalled xapian-core tree). [Changes contributed by Reini Urban] - Force LD to be "g++ -shared" for GCC on Cygwin since Perl < 5.9.5 Cygwin packages need it. 1.0.2.0 Thu Jul 05 15:44:03 BST 2007 [Changes contributed by Olly Betts] - Disable NumberValueRangeProcessor tests, which need updating. 1.0.1.0 Sat Jun 16 00:49:33 BST 2007 [Changes contributed by Olly Betts] - Wrap new optional prefix argument to Database::allterms_begin() and Database::allterms_end(). - Test Database::allterms_begin() in t/search.t. - Increment the reference counts of Stopper and ValueRangeProcessor objects passed to methods of QueryParser and TermGenerator. This means we'll leak them, but that's better than having them garbage collected while the C++ code is still using them. This will be fixed properly in a future release. 1.0.0.0 Sat May 26 00:41:07 BST 2007 [Changes contributed by Olly Betts] - Wrap new TermGenerator class. - Wrap new QueryParser flags FLAG_PURE_NOT and FLAG_PARTIAL. - Wrap new Query op OP_VALUE_RANGE and associated constructor. - Wrap ValueRangeProcessor and subclasses, and QueryParser::add_valuerangeprocessor(). - Removed wrappers for deprecated features which have now been removed from the C++ API. - Fix small memory leaks in various methods when the C++ method throws an exception. - MSet::convert_to_percentage() now actually works (and added feature tests to search.t to make sure it keeps working). - Test WritableDatabase::add_value() in t/index.t. - Test OP_VALUE_RANGE in new t/valuerange.t. - Test ValueRangeProcessor and subclasses in t/parser.t. - More tests for ESetIterator. - Feature tests for new TermGenerator class. - Add "make check" as an alias for "make test". 0.9.10.0 Tue Mar 06 02:27:02 2007 [Changes contributed by Rusty Conover] - Wrap MatchDecider and make it usable with Enquire::get_mset() - Wrap check_at_least parameter of Enquire::get_mset() [Changes contributed by Olly Betts] - Wrap rset parameter of Enquire::get_mset() - Make all get_mset parameter combinations available via Enquire::matches() - Add tests for check_at_least and rset parameters of Enquire::get_mset() - Avoid warning from MakeMaker when generating Makefile for linking against an uninstalled xapian-core tree. - Correct several errors in the pod documentation for Search::Xapian::PositionIterator. 0.9.9.1 Mon Dec 11 06:08:57 2006 [Changes contributed by Olly Betts] - Fix typo in BoolWeight documentation. - Fix BoolWeight default constructor (broken by changes in 0.9.9.0). - Wrap TradWeight class. 0.9.9.0 Mon Nov 09 02:31:09 2006 [Changes contributed by Olly Betts] - Fix the BM25Weight constructors. - Fix problem with isa not being known in Xapian::PostingIterator. - Wrap the newly implemented transaction API to WritableDatabase. 0.9.6.0 Sun Jun 04 01:14:00 2006 [Changes contributed by Olly Betts] - Alex's CPAN email address bounces, so change occurrences of it to direct users to the xapian-discuss mailing list for now. - Correct several occurrences of "Xapian::Search::" to "Search::Xapian::". - Wrap Enquire::set_docid_order (and document set_sort_forward as deprecated.) - Wrap new method Enquire::set_sort_by_relevance_then_value. - Document Enquire::set_sort_by_* (and document set_sorting as deprecated.) - Wrap the BM25Weight constructor which takes parameters (the default one is much less useful, since Xapian defaults to BM25Weight with the default parameters anyway!) - Wrap Enquire::set_sort_by_value_then_relevance() - Wrap the optional flags parameter to QueryParser::parse_query(). - Disable the wrappers for the transaction API to WritableDatabase - it's not implemented by any database backend yet, so it's not useful to wrap it at present. - Fix PostingIterator != and == to handle both other PostingIterators and numbers like PositionIterator does. - Wrap constants FLAG_BOOLEAN_ANY_CASE and FLAG_WILDCARD. - Fix typos and other problems in the POD documentation. Document all constants. - Update the list of unwrapped classes and methods. - Update the version in the README file. Add code to Makefile.PL to check that the various references to the current version are all up-to-date. - Makefile.PL now refuses to proceed if it can't find Xapian. - Makefile.PL now checks that the Xapian version and Search::Xapian version match, and if not issues a non-fatal warning (for now). - Makefile.PL now allows building against an uninstalled xapian-core tree (which is useful when doing development work on Search::Xapian itself). - Add feature test for Document::termlist_begin(). [Changes contributed by Tim Brody] - Add MANIFEST.SKIP to allow "make manifest". 0.9.2.4 Fri Feb 15 14:59:23 2006 [Changes contributed by Olly Betts and Tim Brody] - Catch C++ exceptions from QueryParser and rethrow them as Perl exceptions. - Makefile.PL now checks environmental variable CXX for the C++ compiler to use. - Fixed cross-wired methods inside Enquire::get_matching_terms_begin and Enquire::get_matching_terms_end (thanks to Arne Georg Gleditsch for reporting this). - $q = Query(op, @termlist) now handles terms with embedded zero bytes. - Removed Query::clone() and = overload - they would die if ever used and aren't useful since a Query object is essentially immutable once constructed. - Removed MSet::max_size - C++ only has it so MSet works as an STL container. - RSet::size() returns doccount not termcount (though they're currently the same type underneath so this is an aesthetic internal change). - Wrap most of the changed Xapian::QueryParser API. - Wrap new SimpleStopper class (with test cases). - Added PerlStopper class which can be subclassed in Perl to implement your own stop word algorithm. - Wrap new Enquire sorting API methods. - Updated list of unwrapped classes and methods in documentation. - Make != and == work for comparing iterators (as well as ne and eq). 0.9.2.3 Thu Feb 16 16:57:43 2006 [Changes contributed by Benjamin Smith] - Corrected module names advertised in the POD. - Added new_term method to Search:Xapian::Query. - Fixed the package statement in BoolWeight.pm. - Removed useless prototypes in Search::Xapian::Query. - some extraneous blank lines removed (from >1 lines to just 1 line) [Changes contributed by Peter Karman] - Added set_sort_by_value method to Search::Xapian::Enquire [Changes contributed by Marcus Ramberg] - Fixed get_term_end in Search::Xapian::Query - Added set_stemmer in Search::Xapian::QueryParser - Added get_terms in Search::Xapian::Query 0.9.2.2 Tue Sep 6 16:48:30 2005 [Changes contributed by Marcus Ramberg] - Added a lot of documentation. - Added support for setting weighting schemes in ::Enquire - Added add_prefix and add_boolean_prefix to QueryParser. - Added support for flags to parse_query - Added basic exception handling for QueryParser. 0.9.2.1 Mon Aug 8 12:24:34 2005 - Let perl know Search::Xapian::WritableDatabase is a subclass of Search::Xapian::Database by adding the latter to the former's @INC. 0.9.2.0 Mon Aug 8 12:08:25 2005 - Removed 'set_window', 'set_cutoff', 'set_elite_set_size' and 'set_length' methods from Xapian::Query class - Switched Search::Xapian::Stopper from using now abstract Xapian::Stopper class to Xapian::SimpleStopper subclass. 0.8.4.0 Wed Dec 8 03:36:13 2004 [Changes contributed by Olly Betts] - Changed Database and WritableDatabase constructors to use the new C++ constructors instead of the factory functions. - Eliminated GNU-make-ism from generated Makefile. - Added new test "exception.t" to test C++ -> Perl exception handling. 0.8.3.1 Tue Nov 3 18:25:02 2004 [Changes contributed by Olly Betts] - Fixed handling of optional parameters in Document::add_posting(), Document::add_term(), Document::remove_posting(), Enquire::set_cutoff(), Enquire::set_sorting(), and QueryParser::set_stemming_options(). Added test cases for the first three. - Fixed wrapping of Enquire::get_matching_terms_begin() and get_matching_terms_end(). - Wrap versions of RSet::add_document(), RSet::remove_document(), and RSet::contains() which take MSetIterator instead of a docid. 0.8.3.0 Tue Oct 27 20:32:36 2004 [Changes contributed by Olly Betts] - Fixed exporting of DB_* constants. - Makefile.PL now checks environmental variable XAPIAN_CONFIG. - Wrap missing Database/WritableDatabase methods: get_lastdocid(), positionlist_begin(), and positionlist_end(). - Added WritableDatabase->new() which creates an inmemory database - Wrap missing WritableDatabase methods: delete_document_by_term(), and replace_document_by_term(). - Wrap missing Document methods: remove_value(), and clear_values(). - Fixed usage message if MSet::fetch called with > 3 parameters. - Fixed MSet::convert_to_percent() to actually return a value! - Wrap missing MSetIterator methods: --, get_collapse_count(). - Removed bogus += methods from all iterators (these actually ignored the second argument and always incremented once). - Cleaned up wrapping of ++ methods for all iterators. - Wrap missing ESet methods: back(). - Fixed wrapping of ESetIterator methods: ==, !=. - Wrap 3 argument form of Enquire::set_sorting(). - Wrap missing method PositionIterator::get_description(). - Fixed return value for Query::set_length(). - Wrap missing method Query::empty(). - Second argument to QueryParser::set_stemming_options() may now be omitted. - Wrap ValueIterator class. - Added tests of many of the new and fixed methods. - Documentation now lists unwrapped classes and methods. 0.8.0.4 Wed Jun 9 12:08:54 2004 [Changes contributed by Tim Brody] - Wrappers for ::QueryParser and ::Stopper 0.8.0.3 Thu Jun 3 13:14:39 2004 - Makefile.PL now uses xapian-config to determine library/include path [Changes contributed by Olly Betts] - Wrapped Database::postlist_begin() and postlist_end() - Database::get_doccount(), get_avlength(), and get_termfreq() now return values correctly - WritableDatabase::delete_document() and replace_document() now handle exceptions - Wrapped all methods which WritableDatabase inherits from Database - Fixed 2 warnings when building with GCC 3.3 - Added more test cases to index.t - Corrected typemap - weight is a floating point value; other types are unsigned - Wrapped Stem::get_description() 0.8.0.2 Thu May 13 17:36:45 2004 - More error handling for Query and Document classes - Fully wrapped PositionIterator and PostingIterator - Optional arguments now supported for most methods 0.8.0.1 Wed May 12 18:58:46 2004 - Improved Query class which uses new C++ constructor methods to allow the combination of an unlimited number of terms - More verbose tests, covering all query operations 0.8.0.0 Tue May 4 16:06:41 2004 - New version numbering scheme chases xapian version - Added overloaded function for TermIterator class - Wrapped all methods for Xapian::Enquire (except set_weighting_scheme, which is passed a Weight object - a class for which wrappers do not yet exist). - Replaced AUTOLOAD method designed to reduce code redundancy in Enquire.pm with two separate methods (it was preventing attempts to call unwrapped methods from throwing errors). [Changes contributed by Olly Betts] - Converted to use xapian.h and Xapian:: classnames - add_term is the new preferred name for add_term_nopos - Added stubs for PostingIterator and PositionIterator - String values are now passed in a zero-byte safe way - OM_DB_* renamed to Search::Xapian::DB_* - Now requires Xapian at least version 0.8.0 - Search::Xapian::Database::allterms_end() fixed (was returning the same as Search::Xapian::Database::allterms_begin() 0.05 Tue Jan 14 01:43:45 2003 - OM_DB_CREATE_OR_* symbols wrapped - Extra tests for argument validity for Search::Xapian::Query constructor - Makefile.PL now prints where it has located om/om.h and libxapian.so files [Changes contributed by Olly Betts] - Most methods wrapped for OmESet, OmESetIterator, OmRSet - OmMSet::empty() returns bool, not om_weight - Fixed eq and ne for Search::Xapian::MSetIterator - Fixed Search::Xapian::MSet::convert_to_percent() - Moved #include-s to top of Xapian.xs to fix compilation problems - Added 14 new test cases 0.04 Thu Dec 26 18:17:54 2002 - Convenience method: $enq->set_query( $op, @terms ... ); now autogenerates a query object with the arguments passed if the first of them is not itself a query object - Convenience method: $enq = $db->enquire( [$query] ); which autogenerates Enquire object, calling set_query() if it is passed a query with which to do so - Added tests for tied MSet class - Added $enquire->matches() method returning tied MSet object - Removed deprecated OmSettings class 0.03 Fri Nov 8 16:53:22 2002 - All methods wrapped for OmDatabase, OmWritableDatabase, OmDocument, OmEnquire, OmMSet, OmMSetIterator, OmQuery and OmSettings classes - Overload pragma: copy constructor for all classes that support copying - Overload pragma: '++' for MatchSetIterator - Interface to all overloaded C++ constructors - Mapping for OmQuery::op enumerated type to exported symbols - Removed non-functioning 'MatchSet' method 0.02 Sun Sep 15 19:48:32 2002 - Added bindings to create databases and index documents - Added error handling for Database constructors - 3 test scripts; create, index and search - Fixed MatchSetIterator->get_docid returning wrong value - Fixed string typemap 0.01 Tue Sep 10 16:03:23 2002 - original version; created by h2xs 1.21 with options -x -O -n Search::Xapian -A simplesearch.h Search-Xapian-1.2.25.5/Xapian.xs0000644000175000017500000001726714207006665014726 0ustar ollyolly// Disable any deprecation warnings for Xapian methods/functions/classes. #define XAPIAN_DEPRECATED(D) D #include /* Dummy definition for Xapian < 1.4.2. */ #ifndef XAPIAN_AT_LEAST # define XAPIAN_AT_LEAST(X,Y,Z) 0 #endif #include #include // Stop Perl headers from even thinking of doing '#define bool char' or // '#define bool int', which they would do with compilers other than GCC. #define HAS_BOOL extern "C" { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" } /* Perl's embed.h defines get_context, but that mangles * Xapian::Error::get_context(). */ #ifdef get_context # undef get_context #endif using namespace std; using namespace Xapian; // For some classes, we want extra slots to keep references to set objects in. struct Enquire_perl { Enquire real_obj; SV * sorter; vector matchspies; Enquire_perl(const Xapian::Database & db) : real_obj(db), sorter(NULL) { } void ref_sorter(SV * sv) { SvREFCNT_inc(sv); swap(sv, sorter); SvREFCNT_dec(sv); } void ref_matchspy(SV* sv) { SvREFCNT_inc(sv); matchspies.push_back(sv); } void ref_clear_matchspies(SV* sv) { vector::const_iterator i; for (i = matchspies.begin(); i != matchspies.end(); ++i) { SvREFCNT_dec(*i); } matchspies.clear(); } ~Enquire_perl() { SvREFCNT_dec(sorter); sorter = NULL; ref_clear_matchspies(NULL); } }; struct QueryParser_perl { QueryParser real_obj; SV * stopper; vector vrps; QueryParser_perl() : real_obj(), stopper(NULL) { } void ref_stopper(SV * sv) { SvREFCNT_inc(sv); swap(sv, stopper); SvREFCNT_dec(sv); } void ref_vrp(SV * sv) { SvREFCNT_inc(sv); vrps.push_back(sv); } ~QueryParser_perl() { SvREFCNT_dec(stopper); stopper = NULL; vector::const_iterator i; for (i = vrps.begin(); i != vrps.end(); ++i) { SvREFCNT_dec(*i); } vrps.clear(); } }; struct TermGenerator_perl { TermGenerator real_obj; SV * stopper; TermGenerator_perl() : real_obj(), stopper(NULL) { } void ref_stopper(SV * sv) { SvREFCNT_inc(sv); swap(sv, stopper); SvREFCNT_dec(sv); } ~TermGenerator_perl() { SvREFCNT_dec(stopper); stopper = NULL; } }; #define XAPIAN_PERL_NEW(CLASS, PARAMS) (&((new CLASS##_perl PARAMS)->real_obj)) #define XAPIAN_PERL_CAST(CLASS, OBJ) ((CLASS##_perl*)(void*)(OBJ)) #define XAPIAN_PERL_REF(CLASS, OBJ, MEMB, SV) XAPIAN_PERL_CAST(CLASS, OBJ)->ref_##MEMB(SV) #define XAPIAN_PERL_DESTROY(CLASS, OBJ) delete XAPIAN_PERL_CAST(CLASS, OBJ) extern void handle_exception(void); /* PerlStopper class * * Make operator() call Perl $OBJECT->stop_word */ class PerlStopper : public Stopper { public: PerlStopper(SV * obj) { SV_stopper_ref = newRV_inc(obj); } ~PerlStopper() { sv_2mortal(SV_stopper_ref); } bool operator()(const string &term) const { dSP ; ENTER ; SAVETMPS ; PUSHMARK(SP); PUSHs(SvRV(SV_stopper_ref)); PUSHs(sv_2mortal(newSVpv(term.data(), term.size()))); PUTBACK ; int count = call_method("stop_word", G_SCALAR); SPAGAIN ; if (count != 1) croak("callback function should return 1 value, got %d", count); // Breaks with SvTRUE(POPs) ?!?!?! bool r = SvTRUE(SP[0]); POPs ; PUTBACK ; FREETMPS ; LEAVE ; return r; } private: SV * SV_stopper_ref; }; class perlMatchDecider : public Xapian::MatchDecider { SV *callback; public: perlMatchDecider(SV *func) { callback = newSVsv(func); } ~perlMatchDecider() { SvREFCNT_dec(callback); } bool operator()(const Xapian::Document &doc) const { dSP; ENTER; SAVETMPS; PUSHMARK(SP); SV *arg = sv_newmortal(); Document *pdoc = new Document(doc); sv_setref_pv(arg, "Search::Xapian::Document", (void *)pdoc); XPUSHs(arg); PUTBACK; int count = call_sv(callback, G_SCALAR); SPAGAIN; if (count != 1) croak("callback function should return 1 value, got %d", count); int decide_actual_result = POPi; PUTBACK; FREETMPS; LEAVE; return decide_actual_result; } }; class perlExpandDecider : public Xapian::ExpandDecider { SV *callback; public: perlExpandDecider(SV *func) { callback = newSVsv(func); } ~perlExpandDecider() { SvREFCNT_dec(callback); } bool operator()(const string &term) const { dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newSVpv(term.data(), term.size()))); PUTBACK; int count = call_sv(callback, G_SCALAR); SPAGAIN; if (count != 1) croak("callback function should return 1 value, got %d", count); int decide_actual_result = POPi; PUTBACK; FREETMPS; LEAVE; return decide_actual_result; } }; MODULE = Search::Xapian PACKAGE = Search::Xapian PROTOTYPES: ENABLE string sortable_serialise(double value) double sortable_unserialise(string value) const char * version_string() int major_version() int minor_version() int revision() INCLUDE: XS/BM25Weight.xs INCLUDE: XS/BoolWeight.xs INCLUDE: XS/Database.xs INCLUDE: XS/Document.xs INCLUDE: XS/Enquire.xs INCLUDE: XS/MSet.xs INCLUDE: XS/MSetIterator.xs INCLUDE: XS/ESet.xs INCLUDE: XS/Error.xs INCLUDE: XS/ESetIterator.xs INCLUDE: XS/RSet.xs INCLUDE: XS/MultiValueSorter.xs INCLUDE: XS/Query.xs INCLUDE: XS/QueryParser.xs INCLUDE: XS/SimpleStopper.xs INCLUDE: XS/Stem.xs INCLUDE: XS/Stopper.xs INCLUDE: XS/TermGenerator.xs INCLUDE: XS/TermIterator.xs INCLUDE: XS/TradWeight.xs INCLUDE: XS/PostingIterator.xs INCLUDE: XS/PositionIterator.xs INCLUDE: XS/ValueIterator.xs INCLUDE: XS/WritableDatabase.xs INCLUDE: XS/Weight.xs INCLUDE: XS/DateValueRangeProcessor.xs INCLUDE: XS/NumberValueRangeProcessor.xs INCLUDE: XS/StringValueRangeProcessor.xs INCLUDE: XS/MatchSpy.xs INCLUDE: XS/ValueCountMatchSpy.xs BOOT: { HV *mHvStash = gv_stashpv( "Search::Xapian", TRUE ); // Perl >= probably 5.10 doesn't need the const_cast<> here. #define ENUM_CONST(P, C) newCONSTSUB( mHvStash, const_cast(#P), newSViv(C) ) ENUM_CONST(OP_AND, Query::OP_AND); ENUM_CONST(OP_OR, Query::OP_OR); ENUM_CONST(OP_AND_NOT, Query::OP_AND_NOT); ENUM_CONST(OP_XOR, Query::OP_XOR); ENUM_CONST(OP_AND_MAYBE, Query::OP_AND_MAYBE); ENUM_CONST(OP_FILTER, Query::OP_FILTER); ENUM_CONST(OP_NEAR, Query::OP_NEAR); ENUM_CONST(OP_PHRASE, Query::OP_PHRASE); ENUM_CONST(OP_VALUE_RANGE, Query::OP_VALUE_RANGE); ENUM_CONST(OP_SCALE_WEIGHT, Query::OP_SCALE_WEIGHT); ENUM_CONST(OP_ELITE_SET, Query::OP_ELITE_SET); ENUM_CONST(OP_VALUE_GE, Query::OP_VALUE_GE); ENUM_CONST(OP_VALUE_LE, Query::OP_VALUE_LE); ENUM_CONST(DB_OPEN, DB_OPEN); ENUM_CONST(DB_CREATE, DB_CREATE); ENUM_CONST(DB_CREATE_OR_OPEN, DB_CREATE_OR_OPEN); ENUM_CONST(DB_CREATE_OR_OVERWRITE, DB_CREATE_OR_OVERWRITE); ENUM_CONST(ENQ_DESCENDING, Enquire::DESCENDING); ENUM_CONST(ENQ_ASCENDING, Enquire::ASCENDING); ENUM_CONST(ENQ_DONT_CARE, Enquire::DONT_CARE); ENUM_CONST(FLAG_BOOLEAN, QueryParser::FLAG_BOOLEAN); ENUM_CONST(FLAG_PHRASE, QueryParser::FLAG_PHRASE); ENUM_CONST(FLAG_LOVEHATE, QueryParser::FLAG_LOVEHATE); ENUM_CONST(FLAG_BOOLEAN_ANY_CASE, QueryParser::FLAG_BOOLEAN_ANY_CASE); ENUM_CONST(FLAG_WILDCARD, QueryParser::FLAG_WILDCARD); ENUM_CONST(FLAG_PURE_NOT, QueryParser::FLAG_PURE_NOT); ENUM_CONST(FLAG_PARTIAL, QueryParser::FLAG_PARTIAL); ENUM_CONST(FLAG_SPELLING_CORRECTION, QueryParser::FLAG_SPELLING_CORRECTION); ENUM_CONST(FLAG_SYNONYM, QueryParser::FLAG_SYNONYM); ENUM_CONST(FLAG_AUTO_SYNONYMS, QueryParser::FLAG_AUTO_SYNONYMS); ENUM_CONST(FLAG_AUTO_MULTIWORD_SYNONYMS, QueryParser::FLAG_AUTO_SYNONYMS); ENUM_CONST(FLAG_DEFAULT, QueryParser::FLAG_DEFAULT); ENUM_CONST(STEM_NONE, QueryParser::STEM_NONE); ENUM_CONST(STEM_SOME, QueryParser::STEM_SOME); ENUM_CONST(STEM_ALL, QueryParser::STEM_ALL); ENUM_CONST(FLAG_SPELLING, TermGenerator::FLAG_SPELLING); ENUM_CONST(BAD_VALUENO, BAD_VALUENO); }