1 package Search
::Xapian
::Database
;
8 use Search
::Xapian
::Enquire
;
12 our @ISA = qw(DynaLoader);
14 # In a new thread, copy objects of this class to unblessed, undef values.
17 # Preloaded methods go here.
19 use overload
'=' => sub { $_[0]->clone() },
24 my $enquire = Search
::Xapian
::Enquire
->new( $self );
26 $enquire->set_query( @_ );
34 my $class = ref( $self );
35 my $copy = new2
( $self );
44 if( scalar(@_) == 1 ) {
46 my $arg_class = ref( $arg );
48 $database = new1
( $arg );
49 } elsif( $arg_class eq $class ) {
50 $database = new2
( $arg );
58 Carp
::carp
( "USAGE: $class->new(\$file), $class->new(\$database)" );
61 bless $database, $class;
71 Search::Xapian::Database - Search database object
75 This class represents a Xapian database for searching. See
76 L<Search::Xapian::WritableDatabase> for an object suitable for indexing.
77 To perform searches, this class works with the L<Search::Xapian::Query>
86 Class constructor. Can either take a path to an existing database
87 or another database class as the first parameter
91 Return a clone of this class.
95 Add an existing database (or group of databases) to those accessed by this
100 This re-opens the database(s) to the latest available version(s). It can be
101 used either to make sure the latest results are returned, or to recover from
102 a Xapian::DatabaseModifiedError.
106 Close the database. This also implies a commit() unless a transaction is in
109 =item enquire [<query>]
111 Returns a new L<Search::Xapian::Enquire> object. Any extra
112 parameters are passed to set_query.
116 Returns the number of document indexed in this database.
120 Returns the id of the last used document.
122 =item get_doclength <doc_id>
124 Returns the length of a given document.
126 =item get_document <doc_id>
128 Returns a L<Search::Xapian::Document> object for the given document.
132 Get the average length of the documents in the database.
134 =item get_termfreq <term>
136 Get the number of documents in the database indexed by a given term.
138 =item term_exists <term>
140 returns true if this term exists in the database, or false otherwise.
142 =item get_description
144 return a description of this object.
146 =item get_spelling_suggestion
148 returns a suggested spelling correction.
150 =item allterms_begin [<prefix>]
152 Returns a L<Search::Xapian::TermIterator> iterating over the termlist for the
153 the entire database. If the optional prefix argument is non-empty, only
154 terms starting with that string are returned.
156 =item allterms_end [<prefix>]
158 Returns a L<Search::Xapian::TermIterator> pointing to the end of the
159 termlist corresponding to allterms_begin.
161 =item termlist_begin <docid>
163 Returns a L<Search::Xapian::TermIterator> pointing to the start of the
164 termlist for a given document.
166 =item termlist_end <docid>
168 Returns a L<Search::Xapian::TermIterator> pointing to the end of the
169 termlist for a given document.
171 =item positionlist_begin <docid> <term>
173 Returns a L<Search::Xapian::PositionIterator> pointing to the
174 start of the position list for a given term in the given document.
176 =item positionlist_end <docid> <term>
178 Returns a L<Search::Xapian::PositionIterator> pointing to the end
179 of the position list for a given term in the given document.
181 =item postlist_begin <term>
183 Returns a L<Search::Xapian::PostingIterator> pointing to the
184 start of the posting list for a given term.
186 =item postlist_end <term>
188 Returns a L<Search::Xapian::PostingIterator> pointing to the
189 end of the posting list for a given term.
193 Send a "keep-alive" to remote databases to stop them timing out.
195 =item get_collection_freq <term>
197 Get the number of elements indexed by a certain term.
204 L<Search::Xapian::Enquire>,
205 L<Search::Xapian::WritableDatabase>