[Xapian-devel] 回复: about sort_by_value

Olly Betts olly at survex.com
Thu Mar 27 20:48:08 GMT 2014

On Wed, Mar 26, 2014 at 11:52:57AM +0800, 没有锂称 wrote:
> I need to return 10 results, but Circulation of 16800 times in the
> code,so it is time-consuming. 

I don't understand what you're trying to say here.  The diagram you
sent doesn't help me either.

Are you saying you're searching 16800 times (i.e. once for every
document in the database)?  If so, why?

> Can a one-time reading all the value, sort later return to the
> previous 10?

Are you talking about paging through the results?

If so, you can ask for more results to start with - e.g. call
get_mset(0, 100) and then show that in pages of 10, and if the user goes
beyond page 10, you can fetch another batch of 100.

>   char buf [256];
>   snprintf (buf, sizeof (buf), "% d", i);
>   doc.add_value (200, buf);

Note that the value sort is a *string* sort, so this probably isn't
doing what you want.

I'd suggest:

    doc.add_value(200, Xapian::sortable_serialise(i));

>  How to use, can make sorting faster?  thanks!

I'm really not following what you're trying to do, so it's hard to help.

But generally, if something is too slow, then profile it to find where
the time is spent.


More information about the Xapian-devel mailing list