22 #ifndef XAPIAN_INCLUDED_DATABASE_H
23 #define XAPIAN_INCLUDED_DATABASE_H
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/database.h> directly; include <xapian.h> instead.
31 #include <string_view>
49 class WritableDatabase;
77 static size_t check_(
const std::string_view* path_ptr,
83 void compact_(
const std::string_view* output_ptr,
91 void add_database_(
const Database& other,
bool read_only);
110 add_database_(other,
true);
143 explicit Database(std::string_view path,
int flags = 0);
160 explicit Database(
int fd,
int flags = 0);
247 virtual std::string get_description()
const;
276 bool has_positions()
const;
289 std::string_view
term)
const;
293 std::string_view)
const noexcept {
304 TermIterator allterms_begin(std::string_view prefix = {})
const;
319 double get_average_length()
const;
350 bool term_exists(std::string_view
term)
const;
479 unsigned flags = 0)
const;
491 std::string get_spelling_suggestion(std::string_view word,
492 unsigned max_edit_distance = 2)
const;
553 std::string get_metadata(std::string_view key)
const;
572 metadata_keys_begin(std::string_view prefix = {})
const;
594 std::string get_uuid()
const;
669 static size_t check(std::string_view path,
671 std::ostream* out = NULL) {
672 return check_(&path, 0,
opts, out);
685 static size_t check(
int fd,
int opts = 0, std::ostream* out = NULL) {
686 return check_(NULL, fd,
opts, out);
740 int block_size = 0) {
741 compact_(&output, 0, flags, block_size, NULL);
795 int block_size = 0) {
796 compact_(NULL, fd, flags, block_size, NULL);
854 compact_(&output, 0, flags, block_size, &compactor);
916 compact_(NULL, fd, flags, block_size, &compactor);
940 std::string_view prefix = {},
970 void end_transaction_(
bool do_commit);
995 add_database_(other,
false);
1054 int block_size = 0);
1169 void begin_transaction(
bool flushed =
true);
1259 void delete_document(std::string_view unique_term);
1311 Xapian::docid replace_document(std::string_view unique_term,
1321 void add_spelling(std::string_view word,
1336 termcount remove_spelling(std::string_view word,
1345 void add_synonym(std::string_view
term,
1346 std::string_view synonym)
const;
1354 void remove_synonym(std::string_view
term,
1355 std::string_view synonym)
const;
1362 void clear_synonyms(std::string_view
term)
const;
1406 void set_metadata(std::string_view key, std::string_view metadata);
1409 std::string get_description()
const;
Compiler attribute macros.
#define XAPIAN_NONNULL(LIST)
Annotate function parameters which should be non-NULL pointers.
Compact a database, or merge and compact several.
Virtual base class for Database internals.
An indexed database of documents.
static size_t check(int fd, int opts=0, std::ostream *out=NULL)
Check the integrity of a single file database.
Database(const Database &o)
Copy constructor.
static size_t check(std::string_view path, int opts=0, std::ostream *out=NULL)
Check the integrity of a database or database table.
PositionIterator positionlist_end(Xapian::docid, std::string_view) const noexcept
End iterator corresponding to positionlist_begin().
Xapian::TermIterator spellings_end() const noexcept
End iterator corresponding to spellings_begin().
Database & operator=(Database &&o)
Move assignment operator.
void compact(int fd, unsigned flags, int block_size, Xapian::Compactor &compactor)
Produce a compact version of this database.
double get_avlength() const
Old name for get_average_length() for backward compatibility.
Xapian::TermIterator synonyms_end(std::string_view) const noexcept
End iterator corresponding to synonyms_begin(term).
void add_database(const Database &other)
Add shards from another Database.
Xapian::TermIterator synonym_keys_end(std::string_view={}) const noexcept
End iterator corresponding to synonym_keys_begin(prefix).
Xapian::TermIterator metadata_keys_end(std::string_view={}) const noexcept
End iterator corresponding to metadata_keys_begin().
void compact(int fd, unsigned flags=0, int block_size=0)
Produce a compact version of this database.
TermIterator allterms_end(std::string_view={}) const noexcept
End iterator corresponding to allterms_begin(prefix).
Database(Database &&o)
Move constructor.
void compact(std::string_view output, unsigned flags, int block_size, Xapian::Compactor &compactor)
Produce a compact version of this database.
void compact(std::string_view output, unsigned flags=0, int block_size=0)
Produce a compact version of this database.
PostingIterator postlist_end(std::string_view) const noexcept
End iterator corresponding to postlist_begin().
TermIterator termlist_end(Xapian::docid) const noexcept
End iterator corresponding to termlist_begin().
Database & operator=(const Database &o)
Assignment operator.
ValueIterator valuestream_end(Xapian::valueno) const noexcept
Return end iterator corresponding to valuestream_begin().
Class representing a document.
Class for iterating over term positions.
Class for iterating over a list of terms.
Class for iterating over a list of terms.
Class for iterating over document values.
This class provides read/write access to a database.
void commit_transaction()
Complete the transaction currently in progress.
WritableDatabase(Database::Internal *internal_)
void cancel_transaction()
Abort the transaction currently in progress.
WritableDatabase(const WritableDatabase &o)
Copy constructor.
void add_database(const WritableDatabase &other)
Add shards from another WritableDatabase.
WritableDatabase & operator=(WritableDatabase &&o)
Move assignment operator.
WritableDatabase()
Create a WritableDatabase with no subdatabases.
WritableDatabase & operator=(const WritableDatabase &o)
Assignment operator.
WritableDatabase(WritableDatabase &&o)
Move constructor.
Constants in the Xapian namespace.
The Xapian namespace contains public interfaces for the Xapian library.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
XAPIAN_REVISION_TYPE rev
Revision number of a database.
unsigned valueno
The number for a value slot in a document.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
Class for iterating over term positions.
Class for iterating over a list of document ids.
Class for iterating over a list of terms.
Class for iterating over document values.
Define XAPIAN_VISIBILITY_* macros.
#define XAPIAN_VISIBILITY_DEFAULT
#define XAPIAN_VISIBILITY_INTERNAL