<div dir="ltr"><div>OK£¬ I will try to adjust the code to xapian multi-database, it will spend some time<br><br></div>Thanks!<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/31 Olly Betts <span dir="ltr"><<a href="mailto:olly@survex.com" target="_blank">olly@survex.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, Oct 31, 2013 at 10:24:26AM +0800, jiangwen jiang wrote:<br>
> Yes, there's two choices at the beginning:<br>
> 1. Using multi-database.<br>
> 2. Treat lucene database as a single database.<br>
> Finally, I choose 2. It's a long time ago, I am not quiet sure why this<br>
> decision is made, maybe:<br>
> 1. We can handle multiple lucene databases.<br>
<br>
</div>That should be possible with multi-databases - you'd just end up with a<br>
subdatabase for each segment in all of the lucene databases.  If we make<br>
Xapian::Database's constructor create a Database object with one sub<br>
database per segment in the Lucene database, this sort of thing should<br>
just work:<br>
<br>
    Xapian::Database db;<br>
    db.add_database(Xapian::Database("/path/to/lucene1"));<br>
    db.add_database(Xapian::Database("/path/to/lucene2"));<br>
    db.add_database(Xapian::Database("/path/to/xapian1"));<br>
    db.add_database(Xapian::Database("/path/to/xapian2"));<br>
<div class="im"><br>
> 2. I am not sure if multi-database can meet the requirements, such as:<br>
>    Getting a doc_freq(how many documents contains the term) of a particular<br>
> term, actuallly, I want<br>
>    get sum of doc_freq of a particular term in all lucene segments, I am<br>
> not sure xapian multi-database do it this way.<br>
<br>
</div>A multi-database does sum the "doc_freq" over all subdatabases.<br>
<br>
In general, multi-databases act just like a single database with the<br>
same contents.  There's one exception - when generating an ESet, you<br>
can ask it to approximate statistics by extrapolating from the first<br>
sub database rather than summing over all of them, but you can also<br>
tell it to calculate the exact statistics instead.  This just offers<br>
a trade-off between speed and exactness.<br>
<div class="im"><br>
> Do you think multi-database is a better way to handle lucene database?<br>
<br>
</div>I think so - it seems a natural fit.  Sorry for not thinking of this<br>
earlier.<br>
<br>
Cheers,<br>
    Olly<br>
</blockquote></div><br></div>