[Xapian-discuss] Problem with merge / add database

Olly Betts olly at survex.com
Fri Aug 19 23:10:34 BST 2005


On Tue, Aug 09, 2005 at 09:06:35AM +0200, roki roki wrote:
> i have two databases, which contains different documents, that i want to
> join. Those database having my own doc_id (placed with replace_document).
> Separate searching those database works very well but whan i merge them
> (quartzcompact)
    
Quartzcompact renumbers documents when merging to avoid the risk of
clashes, so won't preserve your docids.

If you actually want to merge two databases preserving docids, then
you could take copydatabase.cc and tweak it to pass the existing docid
when calling add_document.

> or use add_databse i got as result non existing doc_id's.

When you search multiple databases (using Database::add_database) then
the docids in the combined database are remapped by interleaving those
in the underlying database (again to avoid clashes).  But it's easy
enough to map them back.

docid_merged = (docid - 1) * number_of_databases + database_number

where database_number is between 1 and number_of_databases

So:

docid = floor((docid_merged - 1) / number_of_databases) + 1

Cheers,
    Olly



More information about the Xapian-discuss mailing list