Index: matcher/multimatch.cc
===================================================================
--- matcher/multimatch.cc	(revision 7603)
+++ matcher/multimatch.cc	(working copy)
@@ -2,7 +2,7 @@
  *
  * Copyright 1999,2000,2001 BrightStation PLC
  * Copyright 2001,2002 Ananova Ltd
- * Copyright 2002,2003,2004,2005,2006 Olly Betts
+ * Copyright 2002,2003,2004,2005,2006,2007 Olly Betts
  * Copyright 2003 Orange PCS Ltd
  * Copyright 2003 Sam Liddicott
  *
@@ -326,6 +326,8 @@
     Xapian::doccount matches_estimated   = pl->get_termfreq_est();
     Xapian::doccount duplicates_found = 0;
     Xapian::doccount documents_considered = 0;
+    Xapian::doccount mdecider_calls = 0;
+    Xapian::doccount mdecider_hits = 0;
 
     // Check if any results have been asked for (might just be wanting
     // maxweight).
@@ -446,7 +448,9 @@
 		doc = temp;
 	    }
 	    Xapian::Document mydoc(doc.get());
+	    ++mdecider_calls;
 	    if (!mdecider->operator()(mydoc)) continue;
+	    ++mdecider_hits;
 	}
 
 	if (min_item.wt <= 0.0) {
@@ -694,6 +698,16 @@
 	Assert(matches_estimated >= matches_lower_bound);
 	Assert(matches_estimated <= matches_upper_bound);
 
+	if (mdecider_calls) {
+	    // FIXME: need to consider fully how this adjusting of the estimate
+	    // interacts with percent_cutoff and collapse_key...
+	    double accept_rate = double(mdecider_hits) / double(mdecider_calls);
+	    matches_estimated = Xapian::doccount(double(matches_estimated) * accept_rate);
+
+	    matches_estimated = max(matches_estimated, matches_lower_bound);
+	    matches_estimated = min(matches_estimated, matches_upper_bound);
+	}
+
 	if (collapse_key != Xapian::valueno(-1)) {
 	    // Lower bound must be set to no more than the number of collapse
 	    // values we've got, since it's possible that all further hits
