[Xapian-discuss] Result count before fetch

Jesper Krogh jesper at krogh.cc
Sun May 17 20:09:34 BST 2009


Ivo Jansch - Ibuildings wrote:
> Hi,
> 
> I'm working on Xapian integration for Zend Framework, and while writing 
> the wrappers, I was wondering about the following from the example code:
> 
>     $matches = $enquire->get_mset(0, 10);
>  
>       // Display the results.
>       $this->view->count = $matches->get_matches_estimated();
> 
> To be able to use the Xapian results in a Zend_Paginator, I would like 
> to retrieve the amount of matches _before_ I retrieve them using 
> get_mset. Is this possible?
> 
> I thought about using $enquier->get_mset(0,1)->get_matches_estimated()
> 
> but that would mean an extra get_mset call per pageload, which would 
> seem inefficient.

Someone with more insight that me might give a better answer, but I 
think the answer is no, since the estimate is done in the process of
finding the results.

It passes through the index, so if it has reached like 10% through to 
get the 10 matches you requested, then the estimate would be that you 
would have 100 in the total set, allthough it would not be accurate 
unless you actuall requested more than was actually available so you
forced it to visit all hits.

The search terminates when it has found the number of matches you 
requested. (in the regular case, setting sorting changes this).



-- 
Jesper




More information about the Xapian-discuss mailing list