25 #include <initializer_list> 35 #define PROG_NAME "copydatabase" 36 #define PROG_DESC "Perform a document-by-document copy of one or more Xapian databases" 41 cout <<
"Usage: " PROG_NAME " SOURCE_DATABASE... DESTINATION_DATABASE\n\n" 43 " --no-renumber Preserve the numbering of document ids (useful if you have\n" 44 " external references to them, or have set them to match\n" 45 " unique ids from an external source). If multiple source\n" 46 " databases are specified and the same docid occurs in more\n" 47 " one, the last occurrence will be the one which ends up in\n" 48 " the destination database.\n" 49 " --help display this help and exit\n" 50 " --version output version information and exit\n";
55 main(
int argc,
char **argv)
58 if (argc > 1 && argv[1][0] ==
'-') {
59 if (strcmp(argv[1],
"--help") == 0) {
63 if (strcmp(argv[1],
"--version") == 0) {
67 if (strcmp(argv[1],
"--no-renumber") == 0) {
82 const char *dest = argv[argc - 1];
85 for (
int i = 1; i < argc - 1; ++i) {
92 src.resize(src.size() - 1);
106 const char * leaf = src.c_str() + (src.find_last_of(
DIR_SEPS) + 1);
111 cout << leaf <<
": empty!\n";
114 int width =
static_cast<int>(log10(
double(dbsize))) + 1;
131 if (c <= 10 || (dbsize - c) % 13 == 0) {
132 cout <<
'\r' << leaf <<
": ";
133 cout << setw(width) << c <<
'/' << dbsize << flush;
142 cout <<
"Copying spelling data..." << flush;
150 cout <<
"Copying synonym data..." << flush;
153 string key = *synkey;
163 cout <<
"Copying user metadata..." << flush;
166 string key = *metakey;
173 cout <<
"Committing..." << flush;
Xapian::Document get_document(Xapian::docid did) const
Get a document from the database, given its document id.
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
This class is used to access a database, or a group of databases.
const int DB_CREATE
Create a new database.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Xapian::TermIterator synonyms_end(const std::string &) const
Corresponding end iterator to synonyms_begin(term).
void replace_document(Xapian::docid did, const Xapian::Document &document)
Replace a given document in the database.
void set_metadata(const std::string &key, const std::string &metadata)
Set the user-specified metadata associated with a given key.
Xapian::doccount get_doccount() const
Get the number of documents in the database.
std::string get_metadata(const std::string &key) const
Get the user-specified metadata associated with a given key.
Class for iterating over a list of terms.
Class for iterating over a list of terms.
This class provides read/write access to a database.
Xapian::TermIterator spellings_begin() const
An iterator which returns all the spelling correction targets.
Public interfaces for the Xapian library.
Xapian::TermIterator synonym_keys_begin(const std::string &prefix=std::string()) const
An iterator which returns all terms which have synonyms.
Xapian::TermIterator synonym_keys_end(const std::string &=std::string()) const
Corresponding end iterator to synonym_keys_begin(prefix).
void commit()
Commit any pending modifications made to the database.
Xapian::TermIterator synonyms_begin(const std::string &term) const
An iterator which returns all the synonyms for a given term.
std::string get_description() const
Return a string describing this object.
int main(int argc, char **argv)
static void show_usage(int rc)
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Xapian::TermIterator metadata_keys_begin(const std::string &prefix=std::string()) const
An iterator which returns all user-specified metadata keys.
Xapian::TermIterator spellings_end() const
Corresponding end iterator to spellings_begin().
void add_synonym(const std::string &term, const std::string &synonym) const
Add a synonym for a term.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
PostingIterator postlist_end(const std::string &) const
Corresponding end iterator to postlist_begin().
void add_spelling(const std::string &word, Xapian::termcount freqinc=1) const
Add a word to the spelling dictionary.
PostingIterator postlist_begin(const std::string &tname) const
An iterator pointing to the start of the postlist for a given term.
Xapian::TermIterator metadata_keys_end(const std::string &=std::string()) const
Corresponding end iterator to metadata_keys_begin().