FAQ/MultiDatabaseDocumentID

When searching over multiple databases, how do I get convert an MSet entry to the sub-database and docid in it?

Document ids in the combined database are interleaved, so if docid_combined is the docid from the MSet, then the following C code implements this:

subdatabase_number = docid_combined % number_of_databases; // First sub-database is 0.
docid_sub = (docid_combined - 1) / number_of_databases + 1;

If you want to implement this in another language and aren't familiar with C, note that % means modulus in the above.

FAQ Index